home *** CD-ROM | disk | FTP | other *** search
/ The Macintosh Bible Guide to Games / GameGuideCd.bin / Shareware / Miscellaneous / tads22 folder / ADV.T next >
Text File  |  1994-09-14  |  118KB  |  4,264 lines

  1. /* $Header: c:/tads/tads2/RCS/adv.t 1.3 93/01/08 04:36:27 mroberts Prod Locker: mroberts $ */
  2. /* Copyright (c) 1988, 1993 by Michael J. Roberts.  All Rights Reserved. */
  3. /*
  4.    adv.t  - standard adventure definitions for TADS games
  5.    Version 2.2
  6.  
  7.    This file is part of TADS:  The Text Adventure Development System.
  8.    Please see the file LICENSE.DOC (which should be part of the TADS
  9.    distribution) for information on using this file, and for information
  10.    on reaching High Energy Software, the developers of TADS.
  11.  
  12.    This file defines the basic classes and functions used by most TADS
  13.    adventure games.  It is generally #include'd at the start of each game
  14.    source file.
  15. */
  16.  
  17. /* parse adv.t using normal TADS operators */
  18. #pragma C-
  19.  
  20. /*
  21.  *   Define compound prepositions.  Since prepositions that appear in
  22.  *   parsed sentences must be single words, we must define any logical
  23.  *   prepositions that consist of two or more words here.  Note that
  24.  *   only two words can be pasted together at once; to paste more, use
  25.  *   a second step.  For example,  'out from under' must be defined in
  26.  *   two steps:
  27.  *
  28.  *     compoundWord 'out' 'from' 'outfrom';
  29.  *     compoundWord 'outfrom' 'under' 'outfromunder';
  30.  *
  31.  *   Listed below are the compound prepositions that were built in to
  32.  *   version 1.0 of the TADS run-time.
  33.  */
  34. compoundWord 'on' 'to' 'onto';           /* on to --> onto */
  35. compoundWord 'in' 'to' 'into';           /* in to --> into */
  36. compoundWord 'in' 'between' 'inbetween'; /* and so forth */
  37. compoundWord 'down' 'in' 'downin';
  38. compoundWord 'down' 'on' 'downon';
  39. compoundWord 'up' 'on' 'upon';
  40. compoundWord 'out' 'of' 'outof';
  41. compoundWord 'off' 'of' 'offof';
  42. ;
  43.  
  44. /*
  45.  *   Format strings:  these associate keywords with properties.  When
  46.  *   a keyword appears in output between percent signs (%), the matching
  47.  *   property of the current command's actor is evaluated and substituted
  48.  *   for the keyword (and the percent signs).  For example, if you have:
  49.  *
  50.  *      formatstring 'you' fmtYou;
  51.  *
  52.  *   and the command being processed is:
  53.  *
  54.  *      fred, pick up the paper
  55.  *
  56.  *   and the "fred" actor has fmtYou = "he", and this string is output:
  57.  *
  58.  *      "%You% can't see that here."
  59.  *
  60.  *   Then the actual output is:  "He can't see that here."
  61.  *
  62.  *   The format strings are chosen to look like normal output (minus the
  63.  *   percent signs, of course) when the actor is Me.
  64.  */
  65. formatstring 'you' fmtYou;
  66. formatstring 'your' fmtYour;
  67. formatstring 'you\'re' fmtYoure;
  68. formatstring 'youm' fmtYoum;
  69. formatstring 'you\'ve' fmtYouve;
  70. formatstring 's' fmtS;
  71. formatstring 'es' fmtEs;
  72. formatstring 'have' fmtHave;
  73. formatstring 'do' fmtDo;
  74. formatstring 'are' fmtAre;
  75. formatstring 'me' fmtMe;
  76. ;
  77.  
  78. /*
  79.  *   Special Word List: This list defines the special words that the
  80.  *   parser needs for input commands.  If the list is not provided, the
  81.  *   parser uses the old defaults.  The list below is the same as the old
  82.  *   defaults.  Note - the words in this list must appear in the order
  83.  *   shown below.
  84.  */
  85. specialWords
  86.     'of',                        /* used in phrases such as "piece of paper" */
  87.     'and',             /* conjunction for noun lists or to separate commands */
  88.     'then',                              /* conjunction to separate commands */
  89.     'all' = 'everything',               /* refers to every accessible object */
  90.     'both',      /* used with plurals, or to answer disambiguation questions */
  91.     'but' = 'except',                      /* used to exclude items from ALL */
  92.     'one',                       /* used to answer questions:  "the red one" */
  93.     'ones',                        /* likewise for plurals:  "the blue ones" */
  94.     'it' = 'there',              /* refers to last single direct object used */
  95.     'them',                             /* refers to last direct object list */
  96.     'him',                       /* refers to last masculine actor mentioned */
  97.     'her',                        /* refers to last feminine actor mentioned */
  98.     'any' = 'either'         /* pick object arbitrarily from ambiguous list */
  99. ;
  100.  
  101. /*
  102.  *   Forward-declare functions.  This is not required in most cases,
  103.  *   but it doesn't hurt.  Providing these forward declarations ensures
  104.  *   that the compiler knows that we want these symbols to refer to
  105.  *   functions rather than objects.
  106.  */
  107. checkDoor: function;
  108. checkReach: function;
  109. itemcnt: function;
  110. isIndistinguishable: function;
  111. sayPrefixCount: function;
  112. listcont: function;
  113. listcontcont: function;
  114. turncount: function;
  115. addweight: function;
  116. addbulk: function;
  117. incscore: function;
  118. darkTravel: function;
  119. scoreRank: function;
  120. terminate: function;
  121. goToSleep: function;
  122. initSearch: function;
  123. reachableList: function;
  124. initRestart: function;
  125. ;
  126.  
  127. /*
  128.  *   initRestart - flag when a restart has occurred by setting a flag
  129.  *   in global.
  130.  */
  131. initRestart: function(parm)
  132. {
  133.     global.restarting := true;
  134. }
  135.  
  136. /*
  137.  *   checkDoor:  if the door d is open, this function silently returns
  138.  *   the room r.  Otherwise, print a message ("The door is closed.") and
  139.  *   return nil.
  140.  */
  141. checkDoor: function( d, r )
  142. {
  143.     if ( d.isopen ) return( r );
  144.     else
  145.     {
  146.     setit( d );
  147.     caps(); d.thedesc; " is closed. ";
  148.     return( nil );
  149.     }
  150. }
  151.  
  152. /*
  153.  *   checkReach: determines whether the object obj can be reached by
  154.  *   actor in location loc, using the verb v.  This routine returns true
  155.  *   if obj is a special object (numObj or strObj), if obj is in actor's
  156.  *   inventory or actor's location, or if it's in the 'reachable' list for
  157.  *   loc.  
  158.  */
  159. checkReach: function( loc, actor, v, obj )
  160. {
  161.     if ( obj=numObj or obj=strObj ) return;
  162.     if ( not ( actor.isCarrying( obj ) or obj.isIn( actor.location )))
  163.     {
  164.     if (find( loc.reachable, obj ) <> nil ) return;
  165.     "%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". ";
  166.     exit;
  167.     }
  168. }
  169.  
  170. /*
  171.  *  isIndistinguishable: function(obj1, obj2)
  172.  *
  173.  *  Returns true if the two objects are indistinguishable for the purposes
  174.  *  of listing.  The two objects are equivalent if they both have the
  175.  *  isEquivalent property set to true, they both have the same immediate
  176.  *  superclass, and their other listing properties match (in particular,
  177.  *  isworn and (islamp and islit) match for both objects).
  178.  */
  179. isIndistinguishable: function(obj1, obj2)
  180. {
  181.     return (firstsc(obj1) = firstsc(obj2)
  182.             and obj1.isworn = obj2.isworn
  183.             and ((obj1.islamp and obj1.islit)
  184.                  = (obj2.islamp and obj2.islit)));
  185. }
  186.  
  187.  
  188. /*
  189.  *  itemcnt: function( list )
  190.  *
  191.  *  Returns a count of the "listable" objects in list.  An
  192.  *  object is listable (that is, it shows up in a room's description)
  193.  *  if its isListed property is true.  This function is
  194.  *  useful for determining how many objects (if any) will be listed
  195.  *  in a room's description.  Indistinguishable items are counted as
  196.  *  a single item (two items are indistinguishable if they both have
  197.  *  the same immediate superclass, and their isEquivalent properties
  198.  *  are both true.
  199.  */
  200. itemcnt: function( list )
  201. {
  202.     local cnt, tot, i, obj, j;
  203.     tot := length(list);
  204.     cnt := 0;
  205.     i := 1;
  206.     for (i := 1, cnt := 0 ; i <= tot ; ++i)
  207.     {
  208.     /* only consider this item if it's to be listed */
  209.     obj := list[i];
  210.     if (obj.isListed)
  211.     {
  212.         /*
  213.          *   see if there are other equivalent items later in the
  214.          *   list - if so, don't count it (this ensures that each such
  215.          *   item is counted only once, since only the last such item
  216.          *   in the list will be counted) 
  217.          */
  218.         if (obj.isEquivalent)
  219.         {
  220.         local sc;
  221.         
  222.         sc := firstsc(obj);
  223.         for (j := i + 1 ; j <= tot ; ++j)
  224.         {
  225.             if (isIndistinguishable(obj, list[j]))
  226.             goto skip_this_item;
  227.         }
  228.         }
  229.         
  230.         /* count this item */
  231.         ++cnt;
  232.  
  233.     skip_this_item: ;
  234.     }
  235.     }
  236.     return cnt;
  237. }
  238.  
  239. /*
  240.  *  sayPrefixCount: function( cnt )
  241.  *
  242.  *  This function displays a count (suitable for use in listcont when
  243.  *  showing the number of equivalent items.  We display the count spelled out
  244.  *  if it's a small number, otherwise we just display the digits of the
  245.  *  number.
  246.  */
  247. sayPrefixCount: function(cnt)
  248. {
  249.     if (cnt <= 20)
  250.     say(['one' 'two' 'three' 'four' 'five'
  251.          'six' 'seven' 'eight' 'nine' 'ten'
  252.          'eleven' 'twelve' 'thirteen' 'fourteen' 'fifteen'
  253.          'sixteen' 'seventeen' 'eighteen' 'nineteen' 'twenty'][cnt]);
  254.     else
  255.     say(cnt);
  256. }
  257.  
  258. /*
  259.  *  listcont: function( obj )
  260.  *
  261.  *  This function displays the contents of an object, separated by
  262.  *  commas.  The thedesc properties of the contents are used.
  263.  *  It is up to the caller to provide the introduction to the list
  264.  *  (usually something to the effect of "The box contains" is
  265.  *  displayed before calling listcont) and finishing the
  266.  *  sentence (usually by displaying a period).  An object is listed
  267.  *  only if its isListed property is true.  If there are
  268.  *  multiple indistinguishable items in the list, the items are
  269.  *  listed only once (with the number of the items).
  270.  */
  271. listcont: function( obj )
  272. {
  273.     local i, count, tot, list, cur, disptot, prefix_count;
  274.  
  275.     list := obj.contents;
  276.     tot := length( list );
  277.     count := 0;
  278.     disptot := itemcnt( list );
  279.     for (i := 1 ; i <= tot ; ++i)
  280.     {
  281.         cur := list[i];
  282.         if ( cur.isListed )
  283.         {
  284.         /* presume there is only one such object */
  285.         prefix_count := 1;
  286.         
  287.         /*
  288.          *   if this is one of more than one equivalent items, list
  289.          *   it only if it's the first one, and show the number of
  290.          *   such items along with the first one 
  291.          */
  292.         if (cur.isEquivalent)
  293.         {
  294.         local before, after;
  295.         local j;
  296.         local sc;
  297.  
  298.         sc := firstsc(cur);
  299.         for (before := after := 0, j := 1 ; j <= tot ; ++j)
  300.         {
  301.             if (isIndistinguishable(cur, list[j]))
  302.             {
  303.             if (j < i)
  304.                 ++before;
  305.             else
  306.                 ++after;
  307.             }
  308.         }
  309.  
  310.         /*
  311.          *   if there are multiple such objects, and this is the
  312.          *   first such object, list it with the count prefixed;
  313.          *   if there are multiple and this isn't the first one,
  314.          *   skip it; otherwise, go on as normal 
  315.          */
  316.         if (before = 0)
  317.             prefix_count := after;
  318.         else
  319.             continue;
  320.         }
  321.  
  322.             if ( count > 0 )
  323.             {
  324.                 if ( count+1 < disptot )
  325.                     ", ";
  326.                 else if (count = 1)
  327.                     " and ";
  328.                 else
  329.                     ", and ";
  330.             }
  331.  
  332.         /* list the object, along with the number of such items */
  333.         if (prefix_count = 1)
  334.         cur.adesc;
  335.         else
  336.         {
  337.         sayPrefixCount(prefix_count); " ";
  338.         cur.pluraldesc;
  339.         }
  340.  
  341.         /* show any additional information about the item */
  342.             if ( cur.isworn ) " (being worn)";
  343.             if ( cur.islamp and cur.islit ) " (providing light)";
  344.             count := count + 1;
  345.         }
  346.     }
  347. }
  348.  
  349. /*
  350.  *   showcontcont:  list the contents of the object, plus the contents of
  351.  *   an fixeditem's contained by the object.  A complete sentence is shown.
  352.  *   This is an internal routine used by listcontcont and listfixedcontcont.
  353.  */
  354. showcontcont: function( obj )
  355. {
  356.     if (itemcnt( obj.contents ))
  357.     {
  358.         if ( obj.issurface and not obj.isqsurface )
  359.         {
  360.             "Sitting on "; obj.thedesc;" is "; listcont( obj );
  361.             ". ";
  362.         }
  363.         else if ( obj.contentsVisible and not obj.isqcontainer )
  364.         {
  365.             caps();
  366.             obj.thedesc; " seems to contain ";
  367.             listcont( obj );
  368.             ". ";
  369.         }
  370.     }
  371.     if ( obj.contentsVisible and not obj.isqcontainer )
  372.         listfixedcontcont( obj );
  373. }
  374.  
  375. /*
  376.  *  listfixedcontcont: function( obj )
  377.  *
  378.  *  List the contents of the contents of any fixeditem objects
  379.  *  in the contents list of the object obj.  This routine
  380.  *  makes sure that all objects that can be taken are listed somewhere
  381.  *  in a room's description.  This routine recurses down the contents
  382.  *  tree, following each branch until either something has been listed
  383.  *  or the branch ends without anything being listable.  This routine
  384.  *  displays a complete sentence, so no introductory or closing text
  385.  *  is needed.
  386.  */
  387. listfixedcontcont: function( obj )
  388. {
  389.     local list, i, tot, thisobj;
  390.  
  391.     list := obj.contents;
  392.     tot := length( list );
  393.     i := 1;
  394.     while ( i <= tot )
  395.     {
  396.         thisobj := list[i];
  397.         if ( thisobj.isfixed and thisobj.contentsVisible and
  398.       not thisobj.isqcontainer )
  399.             showcontcont( thisobj );
  400.     i := i + 1;
  401.     }
  402. }
  403.  
  404. /*
  405.  *  listcontcont: function( obj )
  406.  *
  407.  *  This function lists the contents of the contents of an object.
  408.  *  It displays full sentences, so no introductory or closing text
  409.  *  is required.  Any item in the contents list of the object
  410.  *  obj whose contentsVisible property is true has
  411.  *  its contents listed.  An Object whose isqcontainer or
  412.  *  isqsurface property is true will not have its
  413.  *  contents listed.
  414.  */
  415. listcontcont: function( obj )
  416. {
  417.     local list, i, tot;
  418.     list := obj.contents;
  419.     tot := length( list );
  420.     i := 1;
  421.     while ( i <= tot )
  422.     {
  423.         showcontcont( list[i] );
  424.     i := i + 1;
  425.     }
  426. }
  427.  
  428. /*
  429.  *  scoreStatus: function(points, turns)
  430.  *
  431.  *  This function updates the score on the status line.  This implementation
  432.  *  simply calls the built-in function setscore() with the same information.
  433.  *  The call to setscore() has been isolated in this function to make it
  434.  *  easier to replace with a customized version; to replace the status line
  435.  *  score display, simply replace this routine.
  436.  */
  437. scoreStatus: function(points, turns)
  438. {
  439.     setscore(points, turns);
  440. }
  441.  
  442. /*
  443.  *  turncount: function( parm )
  444.  *
  445.  *  This function can be used as a daemon (normally set up in the init
  446.  *  function) to update the turn counter after each turn.  This routine
  447.  *  increments global.turnsofar, and then calls setscore to
  448.  *  update the status line with the new turn count.
  449.  */
  450. turncount: function( parm )
  451. {
  452.     incturn();
  453.     global.turnsofar := global.turnsofar + 1;
  454.     scoreStatus( global.score, global.turnsofar );
  455. }
  456.  
  457. /*
  458.  *  addweight: function( list )
  459.  *
  460.  *  Adds the weights of the objects in list and returns the sum.
  461.  *  The weight of an object is given by its weight property.  This
  462.  *  routine includes the weights of all of the contents of each object,
  463.  *  and the weights of their contents, and so forth.
  464.  */
  465. addweight: function( l )
  466. {
  467.     local tot, i, c, totweight;
  468.  
  469.     tot := length( l );
  470.     i := 1;
  471.     totweight := 0;
  472.     while ( i <= tot )
  473.     {
  474.         c := l[i];
  475.         totweight := totweight + c.weight;
  476.         if (length( c.contents ))
  477.             totweight := totweight + addweight( c.contents );
  478.         i := i + 1;
  479.     }
  480.     return( totweight );
  481. }
  482.  
  483. /*
  484.  *  addbulk: function( list )
  485.  *
  486.  *  This function returns the sum of the bulks (given by the bulk
  487.  *  property) of each object in list.  The value returned includes
  488.  *  only the bulk of each object in the list, and not of the contents
  489.  *  of the objects, as it is assumed that an object does not change in
  490.  *  size when something is put inside it.  You can easily change this
  491.  *  assumption for special objects (such as a bag that stretches as
  492.  *  things are put inside) by writing an appropriate bulk method
  493.  *  for that object.
  494.  */
  495. addbulk: function( list )
  496. {
  497.     local i, tot, totbulk, rem, cur;
  498.  
  499.     tot := length( list );
  500.     i := 1;
  501.     totbulk := 0;
  502.     while( i <= tot )
  503.     {
  504.         cur := list[i];
  505.         if ( not cur.isworn )
  506.             totbulk := totbulk + cur.bulk;
  507.         i := i + 1;
  508.     }
  509.     return( totbulk );
  510. }
  511.  
  512. /*
  513.  *  incscore: function( amount )
  514.  *
  515.  *  Adds amount to the total score, and updates the status line
  516.  *  to reflect the new score.  The total score is kept in global.score.
  517.  *  Always use this routine rather than changing global.score
  518.  *  directly, since this routine ensures that the status line is
  519.  *  updated with the new value.
  520.  */
  521. incscore: function( amount )
  522. {
  523.     global.score := global.score + amount;
  524.     scoreStatus( global.score, global.turnsofar );
  525. }
  526.  
  527. /*
  528.  *  initSearch: function
  529.  *
  530.  *  Initializes the containers of objects with a searchLoc, underLoc,
  531.  *  and behindLoc by setting up searchCont, underCont, and
  532.  *  behindCont lists, respectively.  You should call this function once in
  533.  *  your preinit (or init, if you prefer) function to ensure that
  534.  *  the underable, behindable, and searchable objects are set up correctly.
  535.  *  
  536.  *  As a bonus, we take this opportunity to initialize global.floatingList
  537.  *  with a list of all objects of class floatingItem.  It is necessary to
  538.  *  initialize this list, so that validDoList and validIoList include objects
  539.  *  with variable location properties.  Note that, for this to work,
  540.  *  all objects with variable location properties must be declared
  541.  *  to be of class floatingItem.
  542.  */
  543. initSearch: function
  544. {
  545.     local o;
  546.     
  547.     o := firstobj(hiddenItem);
  548.     while (o <> nil)
  549.     {
  550.     if (o.searchLoc)
  551.         o.searchLoc.searchCont := o.searchLoc.searchCont + o;
  552.     else if (o.underLoc)
  553.         o.underLoc.underCont := o.underLoc.underCont + o;
  554.     else if (o.behindLoc)
  555.         o.behindLoc.behindCont := o.behindLoc.behindCont + o;
  556.     o := nextobj(o, hiddenItem);
  557.     }
  558.     
  559.     global.floatingList := [];
  560.     for (o := firstobj(floatingItem) ; o ; o := nextobj(o, floatingItem))
  561.     global.floatingList += o;
  562. }
  563.  
  564. /*
  565.  *  reachableList: function
  566.  *
  567.  *  Returns a list of all the objects reachable from a given object.
  568.  *  That is, if the object is open or is not an openable, it returns the
  569.  *  contents of the object, plus the reachableList result of each object;
  570.  *  if the object is closed, it returns an empty list.
  571.  */
  572. reachableList: function(obj)
  573. {
  574.     local ret := [];
  575.     local i, lst, len;
  576.     
  577.     if (not isclass(obj, openable)
  578.     or (isclass(obj, openable) and obj.isopen))
  579.     {
  580.     lst := obj.contents;
  581.     len := length(lst);
  582.     ret += lst;
  583.     for (i := 1 ; i <= len ; ++i)
  584.         ret += reachableList(lst[i]);
  585.     }
  586.  
  587.     return(ret);
  588. }
  589.  
  590. /*
  591.  *  visibleList: function
  592.  *
  593.  *  This function is similar to reachableList, but returns the
  594.  *  list of objects visible within a given object.
  595.  */
  596. visibleList: function(obj)
  597. {
  598.     local ret := [];
  599.     local i, lst, len;
  600.     
  601.     if (not isclass(obj, openable)
  602.     or (isclass(obj, openable) and obj.isopen)
  603.     or obj.contentsVisible)
  604.     {
  605.     lst := obj.contents;
  606.     len := length(lst);
  607.     ret += lst;
  608.     for (i := 1 ; i <= len ; ++i)
  609.         ret += visibleList(lst[i]);
  610.     }
  611.  
  612.     return(ret);
  613. }
  614.  
  615. /*
  616.  *  nestedroom: room
  617.  *
  618.  *  A special kind of room that is inside another room; chairs and
  619.  *  some types of vehicles, such as inflatable rafts, fall into this
  620.  *  category.  Note that a room can be within another room without
  621.  *  being a nestedroom, simply by setting its location property
  622.  *  to another room.  The nestedroom is different from an ordinary
  623.  *  room, though, in that it's an "open" room; that is, when inside it,
  624.  *  the actor is still really inside the enclosing room for purposes of
  625.  *  descriptions.  Hence, the player sees "Laboratory, in the chair."
  626.  *  In addition, a nestedroom is an object in its own right,
  627.  *  visible to the player; for example, a chair is an object in a
  628.  *  room in addition to being a room itself.  The statusPrep
  629.  *  property displays the preposition in the status description; by
  630.  *  default, it will be "in," but some subclasses and instances
  631.  *  will want to change this to a more appropriate preposition.
  632.  *  outOfPrep is used to report what happens when the player
  633.  *  gets out of the object:  it should be "out of" or "off of" as
  634.  *  appropriate to this object.
  635.  */
  636. class nestedroom: room
  637.     statusPrep = "in"
  638.     outOfPrep = "out of"
  639.     islit =
  640.     {
  641.         if ( self.location ) return( self.location.islit );
  642.         return( nil );
  643.     }
  644.     statusLine =
  645.     {
  646.     "<<self.location.sdesc>>, <<self.statusPrep>> <<self.thedesc>>\n\t";
  647.     }
  648.     lookAround( verbosity ) =
  649.     {
  650.         self.statusLine;
  651.     self.location.nrmLkAround( verbosity );
  652.     }
  653.     roomDrop( obj ) =
  654.     {
  655.         if ( self.location = nil or self.isdroploc ) pass roomDrop;
  656.     else self.location.roomDrop( obj );
  657.     }
  658. ;
  659.  
  660. /*
  661.  *  chairitem: fixeditem, nestedroom, surface
  662.  *
  663.  *  Acts like a chair:  actors can sit on the object.  While sitting
  664.  *  on the object, an actor can't go anywhere until standing up, and
  665.  *  can only reach objects that are on the chair and in the chair's
  666.  *  reachable list.  By default, nothing is in the reachable
  667.  *  list.  Note that there is no real distinction made between chairs
  668.  *  and beds, so you can sit or lie on either; the only difference is
  669.  *  the message displayed describing the situation.
  670.  */
  671. class chairitem: fixeditem, nestedroom, surface
  672.     reachable = ([] + self) // list of all containers reachable from here;
  673.                             //  normally, you can only reach carried items
  674.                             //  from a chair, but this makes special allowances
  675.     ischair = true          // it is a chair by default; for beds or other
  676.                             //  things you lie down on, make it false
  677.     outOfPrep = "out of"
  678.     roomAction( actor, v, dobj, prep, io ) =
  679.     {
  680.         if ( dobj<>nil and v<>inspectVerb )
  681.             checkReach( self, actor, v, dobj );
  682.         if ( io<>nil and v<>askVerb and v<>tellVerb )
  683.             checkReach( self, actor, v, io );
  684.     pass roomAction;
  685.     }
  686.     enterRoom( actor ) = {}
  687.     noexit =
  688.     {
  689.         "%You're% not going anywhere until %you%
  690.         get%s% <<outOfPrep>> <<thedesc>>. ";
  691.         return( nil );
  692.     }
  693.     verDoBoard( actor ) = { self.verDoSiton( actor ); }
  694.     doBoard( actor ) = { self.doSiton( actor ); }
  695.     verDoSiton( actor ) =
  696.     {
  697.         if ( actor.location = self )
  698.         {
  699.             "%You're% already on "; self.thedesc; "! ";
  700.         }
  701.     }
  702.     doSiton( actor ) =
  703.     {
  704.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  705.         actor.travelTo( self );
  706.     }
  707.     verDoLieon( actor ) =
  708.     {
  709.         self.verDoSiton( actor );
  710.     }
  711.     doLieon( actor ) =
  712.     {
  713.         self.doSiton( actor );
  714.     }
  715. ;
  716.  
  717. /*
  718.  *  beditem: chairitem
  719.  *
  720.  *  This object is the same as a chairitem, except that the player
  721.  *  is described as lying on, rather than sitting in, the object.
  722.  */
  723. class beditem: chairitem
  724.     ischair = nil
  725.     isbed = true
  726.     sdesc = "bed"
  727.     statusPrep = "on"
  728.     outOfPrep = "out of"
  729.     doLieon(actor) =
  730.     {
  731.         "Okay, %you're% now lying on <<self.thedesc>>.";
  732.     actor.travelTo(self);
  733.     }
  734. ;
  735.     
  736. /*
  737.  *  floatingItem: object
  738.  *
  739.  *  This class doesn't do anything apart from mark an object as having a
  740.  *  variable location property.  It is necessary to mark all such
  741.  *  items by making them a member of this class, so that the objects are
  742.  *  added to global.floatingList, which is necessary so that floating
  743.  *  objects are included in validDoList and validIoList values (see
  744.  *  the deepverb class for a description of these methods).
  745.  */
  746. class floatingItem: object
  747. ;
  748.  
  749. /*
  750.  *  thing: object
  751.  *
  752.  *  The basic class for objects in a game.  The property contents
  753.  *  is a list that specifies what is in the object; this property is
  754.  *  automatically set up by the system after the game is compiled to
  755.  *  contain a list of all objects that have this object as their
  756.  *  location property.  The contents property is kept
  757.  *  consistent with the location properties of referenced objects
  758.  *  by the moveInto method; always use moveInto rather than
  759.  *  directly setting a location property for this reason.  The
  760.  *  adesc method displays the name of the object with an indefinite
  761.  *  article; the default is to display "a" followed by the sdesc,
  762.  *  but objects that need a different indefinite article (such as "an"
  763.  *  or "some") should override this method.  Likewise, thedesc
  764.  *  displays the name with a definite article; by default, thedesc
  765.  *  displays "the" followed by the object's sdesc.  The sdesc
  766.  *  simply displays the object's name ("short description") without
  767.  *  any articles.  The ldesc is the long description, normally
  768.  *  displayed when the object is examined by the player; by default,
  769.  *  the ldesc displays "It looks like an ordinary sdesc."
  770.  *  The isIn(object) method returns true if the
  771.  *  object's location is the specified object or the object's
  772.  *  location is an object whose contentsVisible property is
  773.  *  true and that object's isIn(object) method is
  774.  *  true.  Note that if isIn is true, it doesn't
  775.  *  necessarily mean the object is reachable, because isIn is
  776.  *  true if the object is merely visible within the location.
  777.  *  The thrudesc method displays a message for when the
  778.  *  player looks through the object (objects such as windows would
  779.  *  use this property).  The moveInto(object) method
  780.  *  moves the object to be inside the specified object.
  781.  *  To make an object disappear, move it into nil.
  782.  */
  783. class thing: object
  784.     weight = 0
  785.     bulk = 1
  786.     isListed = true         // shows up in room/inventory listings
  787.     contents = []           // set up automatically by system - do not set
  788.     verGrab( obj ) = {}
  789.     Grab( obj ) = {}
  790.     adesc =
  791.     {
  792.         "a "; self.sdesc;   // default is "a <name>"; "self" is current object
  793.     }
  794.     pluraldesc =            // default is to add "s" to the sdesc
  795.     {
  796.     self.sdesc; "s";
  797.     }
  798.     thedesc =
  799.     {
  800.         "the "; self.sdesc; // default is "the <name>"
  801.     }
  802.     multisdesc = { self.sdesc; }
  803.     ldesc = { "It looks like an ordinary "; self.sdesc; " to %me%."; }
  804.     readdesc = { "%You% can't read "; self.adesc; ". "; }
  805.     actorAction( v, d, p, i ) =
  806.     {
  807.         "You have lost your mind. ";
  808.         exit;
  809.     }
  810.     contentsVisible = { return( true ); }
  811.     contentsReachable = { return( true ); }
  812.     isIn( obj ) =
  813.     {
  814.         local myloc;
  815.  
  816.         myloc := self.location;
  817.         if ( myloc )
  818.         {
  819.             if ( myloc = obj ) return( true );
  820.             if ( myloc.contentsVisible ) return( myloc.isIn( obj ));
  821.         }
  822.         return( nil );
  823.     }
  824.     thrudesc = { "%You% can't see much through "; self.thedesc; ".\n"; }
  825.     moveInto( obj ) =
  826.     {
  827.         local loc;
  828.  
  829.     /*
  830.      *   For the object containing me, and its container, and so forth,
  831.      *   tell it via a Grab message that I'm going away.
  832.      */
  833.     loc := self.location;
  834.     while ( loc )
  835.     {
  836.         loc.Grab( self );
  837.         loc := loc.location;
  838.     }
  839.  
  840.         if ( self.location )
  841.             self.location.contents := self.location.contents - self;
  842.         self.location := obj;
  843.         if ( obj ) obj.contents := obj.contents + self;
  844.     }
  845.     verDoSave( actor ) =
  846.     {
  847.         "Please specify the name of the game to save in double quotes,
  848.         for example, SAVE \"GAME1\". ";
  849.     }
  850.     verDoRestore( actor ) =
  851.     {
  852.         "Please specify the name of the game to restore in double quotes,
  853.         for example, RESTORE \"GAME1\". ";
  854.     }
  855.     verDoScript( actor ) =
  856.     {
  857.         "You should type the name of a file to write the transcript to
  858.         in quotes, for example, SCRIPT \"LOG1\". ";
  859.     }
  860.     verDoSay( actor ) =
  861.     {
  862.         "You should say what you want to say in double quotes, for example,
  863.         SAY \"HELLO\". ";
  864.     }
  865.     verDoPush( actor ) =
  866.     {
  867.         "Pushing "; self.thedesc; " doesn't do anything. ";
  868.     }
  869.     verDoWear( actor ) =
  870.     {
  871.         "%You% can't wear "; self.thedesc; ". ";
  872.     }
  873.     verDoTake( actor ) =
  874.     {
  875.         if ( self.location = actor )
  876.         {
  877.             "%You% already %have% "; self.thedesc; "! ";
  878.         }
  879.         else self.verifyRemove( actor );
  880.     }
  881.     verifyRemove( actor ) =
  882.     {
  883.       /*
  884.      *   Check with each container to make sure that the container
  885.      *   doesn't object to the object's removal.
  886.      */
  887.         local loc;
  888.  
  889.         loc := self.location;
  890.         while ( loc )
  891.         {
  892.             if ( loc <> actor ) loc.verGrab( self );
  893.             loc := loc.location;
  894.         }
  895.     }
  896.     isVisible( vantage ) =
  897.     {
  898.         local loc;
  899.  
  900.         loc := self.location;
  901.         if ( loc = nil ) return( nil );
  902.  
  903.     /*
  904.      *   if the vantage is inside me, and my contents are visible,
  905.      *   I'm visible 
  906.      */
  907.     if (vantage.location = self and self.contentsVisible)
  908.         return true;
  909.  
  910.         /* if I'm in the vantage, I'm visible */
  911.         if ( loc = vantage ) return( true );
  912.  
  913.         /*
  914.          *   if its location's contents are visible, and its location is
  915.          *   itself visible, it's visible
  916.          */
  917.         if ( loc.contentsVisible and loc.isVisible( vantage )) return( true );
  918.  
  919.         /*
  920.          *   If the vantage has a location, and the vantage's location's
  921.          *   contents are visible (if you can see me I can see you), and
  922.          *   the object is visible from the vantage's location, the object
  923.          *   is visible
  924.          */
  925.         if ( vantage.location <> nil and vantage.location.contentsVisible and
  926.          self.isVisible( vantage.location ))
  927.             return( true );
  928.  
  929.         /* all tests failed:  it's not visible */
  930.         return( nil );
  931.     }
  932.     cantReach( actor ) =
  933.     {
  934.         if ( self.location = nil )
  935.         {
  936.             if ( actor.location.location )
  937.                "%You% can't reach that from << actor.location.thedesc >>. ";
  938.             return;
  939.         }
  940.         if ( not self.location.isopenable or self.location.isopen )
  941.             self.location.cantReach( actor );
  942.         else "%You%'ll have to open << self.location.thedesc >> first. ";
  943.     }
  944.     isReachable( actor ) =
  945.     {
  946.         local loc;
  947.  
  948.         /* if the object is in the room's 'reachable' list, it's reachable */
  949.         if (find( actor.location.reachable, self ) <> nil )
  950.             return( true );
  951.  
  952.         /*
  953.          *   If the object's container's contents are reachable, and the
  954.          *   container is reachable, the object is reachable.
  955.          */
  956.         loc := self.location;
  957.     if (find( actor.location.reachable, self ) <> nil )
  958.         return( true );
  959.     if ( loc = nil ) return( nil );
  960.     if ( loc = actor or loc = actor.location ) return( true );
  961.     if ( loc.contentsReachable )
  962.         return( loc.isReachable( actor ));
  963.     return( nil );
  964.         return( nil );
  965.     }
  966.     doTake( actor ) =
  967.     {
  968.         local totbulk, totweight;
  969.  
  970.         totbulk := addbulk( actor.contents ) + self.bulk;
  971.         totweight := addweight( actor.contents );
  972.         if ( not actor.isCarrying( self ))
  973.             totweight := totweight + self.weight + addweight(self.contents);
  974.  
  975.         if ( totweight > actor.maxweight )
  976.             "%Your% load is too heavy. ";
  977.         else if ( totbulk > actor.maxbulk )
  978.             "%You've% already got %your% hands full. ";
  979.         else
  980.         {
  981.             self.moveInto( actor );
  982.             "Taken. ";
  983.         }
  984.     }
  985.     verDoDrop( actor ) =
  986.     {
  987.         if ( not actor.isCarrying( self ))
  988.         {
  989.             "%You're% not carrying "; self.thedesc; "! ";
  990.         }
  991.         else self.verifyRemove( actor );
  992.     }
  993.     doDrop( actor ) =
  994.     {
  995.         actor.location.roomDrop( self );
  996.     }
  997.     verDoUnwear( actor ) =
  998.     {
  999.         "%You're% not wearing "; self.thedesc; "! ";
  1000.     }
  1001.     verIoPutIn( actor ) =
  1002.     {
  1003.         "%You% can't put anything into "; self.thedesc; ". ";
  1004.     }
  1005.     circularMessage(io) =
  1006.     {
  1007.         local cont;
  1008.  
  1009.     "%You% can't put <<thedesc>> in <<io.thedesc>>, because
  1010.     <<io.thedesc>> is <<io.location = self ? "already" : ""
  1011.         >> <<io.location.issurface ? "on" : "in">> <<io.location.thedesc>>";
  1012.     for (cont := io.location ; cont <> self ; cont := cont.location)
  1013.     {
  1014.         ", which is ";
  1015.             if (cont.location = self) "already ";
  1016.             "<<cont.location.issurface ? "on" : "in"
  1017.             >> <<cont.location.thedesc>>";
  1018.     }
  1019.     ".";
  1020.     }
  1021.     verDoPutIn( actor, io ) =
  1022.     {
  1023.         if ( io = nil ) return;
  1024.  
  1025.         if ( self.location = io )
  1026.         {
  1027.             caps(); self.thedesc; " is already in "; io.thedesc; "! ";
  1028.         }
  1029.         else if (io = self)
  1030.         {
  1031.             "%You% can't put "; self.thedesc; " in itself! ";
  1032.         }
  1033.         else if (io.isIn(self))
  1034.         self.circularMessage(io);
  1035.         else
  1036.             self.verifyRemove( actor );
  1037.     }
  1038.     doPutIn( actor, io ) =
  1039.     {
  1040.         self.moveInto( io );
  1041.         "Done. ";
  1042.     }
  1043.     verIoPutOn( actor ) =
  1044.     {
  1045.         "There's no good surface on "; self.thedesc; ". ";
  1046.     }
  1047.     verDoPutOn( actor, io ) =
  1048.     {
  1049.         if ( io = nil ) return;
  1050.  
  1051.         if ( self.location = io )
  1052.         {
  1053.             caps(); self.thedesc; " is already on "; io.thedesc; "! ";
  1054.         }
  1055.     else if (io = self)
  1056.         {
  1057.             "%You% can't put "; self.thedesc; " on itself! ";
  1058.         }
  1059.     else if (io.isIn(self))
  1060.         self.circularMessage(io);
  1061.         else
  1062.         self.verifyRemove( actor );
  1063.     }
  1064.     doPutOn( actor, io ) =
  1065.     {
  1066.         self.moveInto( io );
  1067.         "Done. ";
  1068.     }
  1069.     verIoTakeOut( actor ) = {}
  1070.     ioTakeOut( actor, dobj ) =
  1071.     {
  1072.         dobj.doTakeOut( actor, self );
  1073.     }
  1074.     verDoTakeOut( actor, io ) =
  1075.     {
  1076.         if ( io <> nil and not self.isIn( io ))
  1077.         {
  1078.             caps(); self.thedesc; " isn't in "; io.thedesc; ". ";
  1079.         }
  1080.     self.verDoTake(actor);         /* ensure object can be taken at all */
  1081.     }
  1082.     doTakeOut( actor, io ) =
  1083.     {
  1084.         self.doTake( actor );
  1085.     }
  1086.     verIoTakeOff( actor ) = {}
  1087.     ioTakeOff( actor, dobj ) =
  1088.     {
  1089.         dobj.doTakeOff( actor, self );
  1090.     }
  1091.     verDoTakeOff( actor, io ) =
  1092.     {
  1093.         if ( io <> nil and not self.isIn( io ))
  1094.         {
  1095.             caps(); self.thedesc; " isn't on "; io.thedesc; "! ";
  1096.         }
  1097.     self.verDoTake(actor);         /* ensure object can be taken at all */
  1098.     }
  1099.     doTakeOff( actor, io ) =
  1100.     {
  1101.         self.doTake( actor );
  1102.     }
  1103.     verIoPlugIn( actor ) =
  1104.     {
  1105.         "%You% can't plug anything into "; self.thedesc; ". ";
  1106.     }
  1107.     verDoPlugIn( actor, io ) =
  1108.     {
  1109.         "%You% can't plug "; self.thedesc; " into anything. ";
  1110.     }
  1111.     verIoUnplugFrom( actor ) =
  1112.     {
  1113.         "It's not plugged into "; self.thedesc; ". ";
  1114.     }
  1115.     verDoUnplugFrom( actor, io ) =
  1116.     {
  1117.         if ( io <> nil ) { "It's not plugged into "; io.thedesc; ". "; }
  1118.     }
  1119.     verDoLookin( actor ) =
  1120.     {
  1121.         "There's nothing in "; self.thedesc; ". ";
  1122.     }
  1123.     verDoLookthru( actor ) =
  1124.     {
  1125.         "%You% can't see anything through "; self.thedesc; ". ";
  1126.     }
  1127.     verDoLookunder( actor ) =
  1128.     {
  1129.         "There's nothing under "; self.thedesc; ". ";
  1130.     }
  1131.     verDoInspect( actor ) = {}
  1132.     doInspect( actor ) =
  1133.     {
  1134.         self.ldesc;
  1135.     }
  1136.     verDoRead( actor ) =
  1137.     {
  1138.         "I don't know how to read "; self.thedesc; ". ";
  1139.     }
  1140.     verDoLookbehind( actor ) =
  1141.     {
  1142.         "There's nothing behind "; self.thedesc; ". ";
  1143.     }
  1144.     verDoTurn( actor ) =
  1145.     {
  1146.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1147.     }
  1148.     verDoTurnWith( actor, io ) =
  1149.     {
  1150.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1151.     }
  1152.     verDoTurnTo( actor, io ) =
  1153.     {
  1154.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1155.     }
  1156.     verIoTurnTo( actor ) =
  1157.     {
  1158.         "I don't know how to do that. ";
  1159.     }
  1160.     verDoTurnon( actor ) =
  1161.     {
  1162.         "I don't know how to turn "; self.thedesc; " on. ";
  1163.     }
  1164.     verDoTurnoff( actor ) =
  1165.     {
  1166.         "I don't know how to turn "; self.thedesc; " off. ";
  1167.     }
  1168.     verIoAskAbout( actor ) = {}
  1169.     ioAskAbout( actor, dobj ) =
  1170.     {
  1171.         dobj.doAskAbout( actor, self );
  1172.     }
  1173.     verDoAskAbout( actor, io ) =
  1174.     {
  1175.         "Surely, %you% can't think "; self.thedesc; " knows anything
  1176.         about it! ";
  1177.     }
  1178.     verIoTellAbout( actor ) = {}
  1179.     ioTellAbout( actor, dobj ) =
  1180.     {
  1181.         dobj.doTellAbout( actor, self );
  1182.     }
  1183.     verDoTellAbout( actor, io ) =
  1184.     {
  1185.         "It doesn't look as though "; self.thedesc; " is interested. ";
  1186.     }
  1187.     verDoUnboard( actor ) =
  1188.     {
  1189.         if ( actor.location <> self )
  1190.         {
  1191.             "%You're% not in "; self.thedesc; "! ";
  1192.         }
  1193.         else if ( self.location=nil )
  1194.         {
  1195.             "%You% can't get out of "; self.thedesc; "! ";
  1196.         }
  1197.     }
  1198.     doUnboard( actor ) =
  1199.     {
  1200.         if ( self.fastenitem )
  1201.     {
  1202.         "%You%'ll have to unfasten "; actor.location.fastenitem.thedesc;
  1203.         " first. ";
  1204.     }
  1205.     else
  1206.     {
  1207.             "Okay, %you're% no longer in "; self.thedesc; ". ";
  1208.             self.leaveRoom( actor );
  1209.         actor.moveInto( self.location );
  1210.     }
  1211.     }
  1212.     verDoAttackWith( actor, io ) =
  1213.     {
  1214.         "Attacking "; self.thedesc; " doesn't appear productive. ";
  1215.     }
  1216.     verIoAttackWith( actor ) =
  1217.     {
  1218.         "It's not very effective to attack with "; self.thedesc; ". ";
  1219.     }
  1220.     verDoEat( actor ) =
  1221.     {
  1222.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1223.     }
  1224.     verDoDrink( actor ) =
  1225.     {
  1226.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1227.     }
  1228.     verDoGiveTo( actor, io ) =
  1229.     {
  1230.         if ( not actor.isCarrying( self ))
  1231.         {
  1232.             "%You're% not carrying "; self.thedesc; ". ";
  1233.         }
  1234.         else self.verifyRemove( actor );
  1235.     }
  1236.     doGiveTo( actor, io ) =
  1237.     {
  1238.         self.moveInto( io );
  1239.         "Done. ";
  1240.     }
  1241.     verDoPull( actor ) =
  1242.     {
  1243.         "Pulling "; self.thedesc; " doesn't have any effect. ";
  1244.     }
  1245.     verDoThrowAt( actor, io ) =
  1246.     {
  1247.         if ( not actor.isCarrying( self ))
  1248.         {
  1249.             "%You're% not carrying "; self.thedesc; ". ";
  1250.         }
  1251.         else self.verifyRemove( actor );
  1252.     }
  1253.     doThrowAt( actor, io ) =
  1254.     {
  1255.         "%You% miss%es%. ";
  1256.         self.moveInto( actor.location );
  1257.     }
  1258.     verIoThrowAt( actor ) =
  1259.     {
  1260.         if ( actor.isCarrying( self ))
  1261.         {
  1262.             "%You% could at least drop "; self.thedesc; " first. ";
  1263.         }
  1264.     }
  1265.     ioThrowAt( actor, dobj ) =
  1266.     {
  1267.         dobj.doThrowAt( actor, self );
  1268.     }
  1269.     verDoThrowTo( actor, io ) =
  1270.     {
  1271.         if ( not actor.isCarrying( self ))
  1272.         {
  1273.             "%You're% not carrying "; self.thedesc; ". ";
  1274.         }
  1275.         else self.verifyRemove( actor );
  1276.     }
  1277.     doThrowTo( actor, io ) =
  1278.     {
  1279.         "%You% miss%es%. ";
  1280.         self.moveInto( actor.location );
  1281.     }
  1282.     verDoThrow( actor ) =
  1283.     {
  1284.         if ( not actor.isCarrying( self ))
  1285.         {
  1286.             "%You're% not carrying "; self.thedesc; ". ";
  1287.         }
  1288.         else self.verifyRemove( actor );
  1289.     }
  1290.     doThrow( actor ) =
  1291.     {
  1292.         "Thrown. ";
  1293.         self.moveInto( actor.location );
  1294.     }
  1295.     verDoShowTo( actor, io ) =
  1296.     {
  1297.     }
  1298.     doShowTo( actor, io ) =
  1299.     {
  1300.         if ( io <> nil ) { caps(); io.thedesc; " isn't impressed. "; }
  1301.     }
  1302.     verIoShowTo( actor ) =
  1303.     {
  1304.         caps(); self.thedesc; " isn't impressed. ";
  1305.     }
  1306.     verDoClean( actor ) =
  1307.     {
  1308.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1309.     }
  1310.     verDoCleanWith( actor, io ) = {}
  1311.     doCleanWith( actor, io ) =
  1312.     {
  1313.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1314.     }
  1315.     verDoMove( actor ) =
  1316.     {
  1317.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1318.     }
  1319.     verDoMoveTo( actor, io ) =
  1320.     {
  1321.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1322.     }
  1323.     verIoMoveTo( actor ) =
  1324.     {
  1325.         "That doesn't get us anywhere. ";
  1326.     }
  1327.     verDoMoveWith( actor, io ) =
  1328.     {
  1329.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1330.     }
  1331.     verIoMoveWith( actor ) =
  1332.     {
  1333.         caps(); self.thedesc; " doesn't seem to help. ";
  1334.     }
  1335.     verDoTypeOn( actor, io ) =
  1336.     {
  1337.         "You should say what you want to type in double quotes, for
  1338.         example, TYPE \"HELLO\" ON KEYBOARD. ";
  1339.     }
  1340.     verDoTouch( actor ) =
  1341.     {
  1342.         "Touching "; self.thedesc; " doesn't seem to have any effect. ";
  1343.     }
  1344.     verDoPoke( actor ) =
  1345.     {
  1346.         "Poking "; self.thedesc; " doesn't seem to have any effect. ";
  1347.     }
  1348.     verDoBreak(actor) = {}
  1349.     doBreak(actor) =
  1350.     {
  1351.     "You'll have to tell me how to do that.";
  1352.     }
  1353.     genMoveDir = { "%You% can't seem to do that. "; }
  1354.     verDoMoveN( actor ) = { self.genMoveDir; }
  1355.     verDoMoveS( actor ) = { self.genMoveDir; }
  1356.     verDoMoveE( actor ) = { self.genMoveDir; }
  1357.     verDoMoveW( actor ) = { self.genMoveDir; }
  1358.     verDoMoveNE( actor ) = { self.genMoveDir; }
  1359.     verDoMoveNW( actor ) = { self.genMoveDir; }
  1360.     verDoMoveSE( actor ) = { self.genMoveDir; }
  1361.     verDoMoveSW( actor ) = { self.genMoveDir; }
  1362.     verDoSearch( actor ) =
  1363.     {
  1364.         "%You% find%s% nothing of interest. ";
  1365.     }
  1366.  
  1367.     /* on dynamic construction, move into my contents list */
  1368.     construct =
  1369.     {
  1370.     self.moveInto(location);
  1371.     }
  1372.  
  1373.     /* on dynamic destruction, move out of contents list */
  1374.     destruct =
  1375.     {
  1376.     self.moveInto(nil);
  1377.     }
  1378.  
  1379.     /*
  1380.      *   Make it so that the player can give a command to an actor only
  1381.      *   if an actor is reachable in the normal manner.  This method
  1382.      *   returns true when 'self' can be given a command by the player. 
  1383.      */
  1384.     validActor = (self.isReachable(Me))
  1385. ;
  1386.  
  1387. /*
  1388.  *  item: thing
  1389.  *
  1390.  *  A basic item which can be picked up by the player.  It has no weight
  1391.  *  (0) and minimal bulk (1).  The weight property should be set
  1392.  *  to a non-zero value for heavy objects.  The bulk property
  1393.  *  should be set to a value greater than 1 for bulky objects, and to
  1394.  *  zero for objects that are very small and take essentially no effort
  1395.  *  to hold---or, more precisely, don't detract at all from the player's
  1396.  *  ability to hold other objects (for example, a piece of paper).
  1397.  */
  1398. class item: thing
  1399.     weight = 0
  1400.     bulk = 1
  1401. ;
  1402.     
  1403. /*
  1404.  *  lightsource: item
  1405.  *
  1406.  *  A portable lamp, candle, match, or other source of light.  The
  1407.  *  light source can be turned on and off with the islit property.
  1408.  *  If islit is true, the object provides light, otherwise it's
  1409.  *  just an ordinary object.  Note that this object provides a doTurnon
  1410.  *  method to provide appropriate behavior for a switchable light source,
  1411.  *  such as a flashlight or a room's electric lights.  However, this object
  1412.  *  does not provide a verDoTurnon method, so by default it can't be
  1413.  *  switched on and off.  To create something like a flashlight that should
  1414.  *  be a lightsource that can be switched on and off, simply include both
  1415.  *  lightsource and switchItem in the superclass list, and be sure
  1416.  *  that lightsource precedes switchItem in the superclass list,
  1417.  *  because the doTurnon method provided by lightsource should
  1418.  *  override the one provided by switchItem.  The doTurnon method
  1419.  *  provided here turns on the light source (by setting its isActive
  1420.  *  property to true, and then describes the room if it was previously
  1421.  *  dark.
  1422.  */
  1423. class lightsource: item
  1424.     islamp = true
  1425.     doTurnon(actor) =
  1426.     {
  1427.     local waslit := actor.location.islit;
  1428.  
  1429.     // turn on the light
  1430.     self.isActive := true;
  1431.     "You switch on <<thedesc>>";
  1432.  
  1433.     // if the room wasn't previously lit, and it is now, describe it
  1434.     if (actor.location.islit and not waslit)
  1435.     {
  1436.         ", lighting the area.\b";
  1437.         actor.location.enterRoom(actor);
  1438.     }
  1439.     else
  1440.         ".";
  1441.     }
  1442. ;
  1443.  
  1444. /*
  1445.  *  hiddenItem: object
  1446.  *
  1447.  *  This is an object that is hidden with one of the hider classes. 
  1448.  *  A hiddenItem object doesn't have any special properties in its
  1449.  *  own right, but all objects hidden with one of the hider classes
  1450.  *  must be of class hiddenItem so that initSearch can find
  1451.  *  them.
  1452.  */
  1453. class hiddenItem: object
  1454. ;
  1455.  
  1456. /*
  1457.  *  hider: item
  1458.  *
  1459.  *  This is a basic class of object that can hide other objects in various
  1460.  *  ways.  The underHider, behindHider, and searchHider classes
  1461.  *  are examples of hider subclasses.  The class defines
  1462.  *  the method searchObj(actor, list), which is given the list
  1463.  *  of hidden items contained in the object (for example, this would be the
  1464.  *  underCont property, in the case of an underHider), and "finds"
  1465.  *  the object or objects. Its action is dependent upon a couple of other
  1466.  *  properties of the hider object.  The serialSearch property,
  1467.  *  if true, indicates that items in the list are to be found one at
  1468.  *  a time; if nil (the default), the entire list is found on the
  1469.  *  first try.  The autoTake property, if true, indicates that
  1470.  *  the actor automatically takes the item or items found; if nil, the
  1471.  *  item or items are moved to the actor's location.  The searchObj method
  1472.  *  returns the list with the found object or objects removed; the
  1473.  *  caller should assign this returned value back to the appropriate
  1474.  *  property (for example, underHider will assign the return value
  1475.  *  to underCont).
  1476.  *  
  1477.  *  Note that because the hider is hiding something, this class
  1478.  *  overrides the normal verDoSearch method to display the
  1479.  *  message, "You'll have to be more specific about how you want
  1480.  *  to search that."  The reason is that the normal verDoSearch
  1481.  *  message ("You find nothing of interest") leads players to believe
  1482.  *  that the object was exhaustively searched, and we want to avoid
  1483.  *  misleading the player.  On the other hand, we don't want a general
  1484.  *  search to be exhaustive for most hider objects.  So, we just
  1485.  *  display a message letting the player know that the search was not
  1486.  *  enough, but we don't give away what they have to do instead.
  1487.  *  
  1488.  *  The objects hidden with one of the hider classes must be
  1489.  *  of class hiddenItem.
  1490.  */
  1491. class hider: item
  1492.     verDoSearch(actor) =
  1493.     {
  1494.     "%You%'ll have to be more specific about how %you% want%s%
  1495.     to search that. ";
  1496.     }
  1497.     searchObj(actor, list) =
  1498.     {
  1499.     local found, dest, i, tot;
  1500.  
  1501.     /* see how much we get this time */
  1502.     if (self.serialSearch)
  1503.     {
  1504.         found := [] + car(list);
  1505.         list := cdr(list);
  1506.     }
  1507.     else
  1508.     {
  1509.         found := list;
  1510.         list := nil;
  1511.     }
  1512.  
  1513.     /* set it(them) to the found item(s) */
  1514.         if (length(found) = 1)
  1515.         setit(found[1]);    // only one item - set 'it'
  1516.     else
  1517.         setit(found);       // multiple items - set 'them'
  1518.  
  1519.     /* figure destination */
  1520.     dest := actor;
  1521.     if (not self.autoTake) dest := dest.location;
  1522.     
  1523.     /* note what we found, and move it to destination */
  1524.     "%You% find%s% ";
  1525.     tot := length(found);
  1526.     i := 1;
  1527.     while (i <= tot)
  1528.     {
  1529.         found[i].adesc;
  1530.         if (i+1 < tot) ", ";
  1531.         else if (i = 1 and tot = 2) " and ";
  1532.         else if (i+1 = tot and tot > 2) ", and ";
  1533.         
  1534.         found[i].moveInto(dest);
  1535.         i := i + 1;
  1536.     }
  1537.  
  1538.     /* say what happened */
  1539.     if (self.autoTake) ", which %you% take%s%. ";
  1540.     else "! ";
  1541.  
  1542.     if (list<>nil and length(list)=0) list := nil;
  1543.     return(list);
  1544.     }
  1545.     serialSearch = nil             /* find everything in one try by default */
  1546.     autoTake = true               /* actor takes item when found by default */
  1547. ;
  1548.  
  1549. /*
  1550.  *  underHider: hider
  1551.  *
  1552.  *  This is an object that can have other objects placed under it.  The
  1553.  *  objects placed under it can only be found by looking under the object;
  1554.  *  see the description of hider for more information.  You should
  1555.  *  set the underLoc property of each hidden object to point to
  1556.  *  the underHider.
  1557.  *  
  1558.  *  Note that an underHider doesn't allow the player to put anything
  1559.  *  under the object during the game.  Instead, it's to make it easy for the
  1560.  *  game writer to set up hidden objects while implementing the game.  All you
  1561.  *  need to do to place an object under another object is declare the top
  1562.  *  object as an underHider, then declare the hidden object normally,
  1563.  *  except use underLoc rather than location to specify the
  1564.  *  location of the hidden object.  The behindHider and searchHider
  1565.  *  objects work similarly.
  1566.  *  
  1567.  *  The objects hidden with underHider must be of class hiddenItem.
  1568.  */
  1569. class underHider: hider
  1570.     underCont = []         /* list of items under me (set up by initSearch) */
  1571.     verDoLookunder(actor) = {}
  1572.     doLookunder(actor) =
  1573.     {
  1574.     if (self.underCont = nil)
  1575.         "There's nothing else under <<self.thedesc>>. ";
  1576.     else
  1577.         self.underCont := self.searchObj(actor, self.underCont);
  1578.     }
  1579. ;
  1580.  
  1581. /*
  1582.  *  behindHider: hider
  1583.  *
  1584.  *  This is just like an underHider, except that objects are hidden
  1585.  *  behind this object.  Objects to be behind this object should have their
  1586.  *  behindLoc property set to point to this object.
  1587.  *  
  1588.  *  The objects hidden with behindHider must be of class hiddenItem.
  1589.  */
  1590. class behindHider: hider
  1591.     behindCont = []
  1592.     verDoLookbehind(actor) = {}
  1593.     doLookbehind(actor) =
  1594.     {
  1595.     if (self.behindCont = nil)
  1596.         "There's nothing else behind <<self.thedesc>>. ";
  1597.     else
  1598.         self.behindCont := self.searchObj(actor, self.behindCont);
  1599.     }
  1600. ;
  1601.     
  1602. /*
  1603.  *  searchHider: hider
  1604.  *
  1605.  *  This is just like an underHider, except that objects are hidden
  1606.  *  within this object in such a way that the object must be looked in
  1607.  *  or searched.  Objects to be hidden in this object should have their
  1608.  *  searchLoc property set to point to this object.  Note that this
  1609.  *  is different from a normal container, in that the objects hidden within
  1610.  *  this object will not show up until the object is explicitly looked in
  1611.  *  or searched.
  1612.  *  
  1613.  *  The items hidden with searchHider must be of class hiddenItem.
  1614.  */
  1615. class searchHider: hider
  1616.     searchCont = []
  1617.     verDoSearch(actor) = {}
  1618.     doSearch(actor) =
  1619.     {
  1620.     if (self.searchCont = nil)
  1621.         "There's nothing else in <<self.thedesc>>. ";
  1622.     else
  1623.         self.searchCont := self.searchObj(actor, self.searchCont);
  1624.     }
  1625.     verDoLookin(actor) =
  1626.     {
  1627.     if (self.searchCont = nil)
  1628.         pass verDoLookin;
  1629.     }
  1630.     doLookin(actor) =
  1631.     {
  1632.     if (self.searchCont = nil)
  1633.         pass doLookin;
  1634.     else
  1635.         self.searchCont := self.searchObj(actor, self.searchCont);
  1636.     }
  1637. ;
  1638.     
  1639.  
  1640. /*
  1641.  *  fixeditem: thing
  1642.  *
  1643.  *  An object that cannot be taken or otherwise moved from its location.
  1644.  *  Note that a fixeditem is sometimes part of a movable object;
  1645.  *  this can be done to make one object part of another, ensuring that
  1646.  *  they cannot be separated.  By default, the functions that list a room's
  1647.  *  contents do not automatically describe fixeditem objects (because
  1648.  *  the isListed property is set to nil).  Instead, the game author
  1649.  *  will generally describe the fixeditem objects separately as part of
  1650.  *  the room's ldesc.  
  1651.  */
  1652. class fixeditem: thing      // An immovable object
  1653.     isListed = nil          // not listed in room/inventory displays
  1654.     isfixed = true          // Item can't be taken
  1655.     weight = 0              // no actual weight
  1656.     bulk = 0
  1657.     verDoTake( actor ) =
  1658.     {
  1659.         "%You% can't have "; self.thedesc; ". ";
  1660.     }
  1661.     verDoTakeOut( actor, io ) =
  1662.     {
  1663.         self.verDoTake( actor );
  1664.     }
  1665.     verDoDrop( actor ) =
  1666.     {
  1667.         "%You% can't drop "; self.thedesc; ". ";
  1668.     }
  1669.     verDoTakeOff( actor, io ) =
  1670.     {
  1671.         self.verDoTake( actor );
  1672.     }
  1673.     verDoPutIn( actor, io ) =
  1674.     {
  1675.         "%You% can't put "; self.thedesc; " anywhere. ";
  1676.     }
  1677.     verDoPutOn( actor, io ) =
  1678.     {
  1679.         "%You% can't put "; self.thedesc; " anywhere. ";
  1680.     }
  1681.     verDoMove( actor ) =
  1682.     {
  1683.         "%You% can't move "; self.thedesc; ". ";
  1684.     }
  1685.     verDoThrowAt(actor, iobj) =
  1686.     {
  1687.         "%You% can't throw <<self.thedesc>>.";
  1688.     }
  1689. ;
  1690.  
  1691. /*
  1692.  *  readable: item
  1693.  *
  1694.  *  An item that can be read.  The readdesc property is displayed
  1695.  *  when the item is read.  By default, the readdesc is the same
  1696.  *  as the ldesc, but the readdesc can be overridden to give
  1697.  *  a different message.
  1698.  */
  1699. class readable: item
  1700.     verDoRead( actor ) =
  1701.     {
  1702.     }
  1703.     doRead( actor ) =
  1704.     {
  1705.         self.readdesc;
  1706.     }
  1707.     readdesc =
  1708.     {
  1709.         self.ldesc;
  1710.     }
  1711. ;
  1712.  
  1713. /*
  1714.  *  fooditem: item
  1715.  *
  1716.  *  An object that can be eaten.  When eaten, the object is removed from
  1717.  *  the game, and global.lastMealTime is decremented by the
  1718.  *  foodvalue property.  By default, the foodvalue property
  1719.  *  is global.eatTime, which is the time between meals.  So, the
  1720.  *  default fooditem will last for one "nourishment interval."
  1721.  */
  1722. class fooditem: item
  1723.     verDoEat( actor ) =
  1724.     {
  1725.         self.verifyRemove( actor );
  1726.     }
  1727.     doEat( actor ) =
  1728.     {
  1729.         "That was delicious! ";
  1730.         global.lastMealTime := global.lastMealTime - self.foodvalue;
  1731.         self.moveInto( nil );
  1732.     }
  1733.     foodvalue = { return( global.eatTime ); }
  1734. ;
  1735.  
  1736. /*
  1737.  *  dialItem: fixeditem
  1738.  *
  1739.  *  This class is used for making "dials," which are controls in
  1740.  *  your game that can be turned to a range of numbers.  You must
  1741.  *  define the property maxsetting as a number specifying the
  1742.  *  highest number to which the dial can be turned; the lowest number
  1743.  *  on the dial is always 1.  The setting property is the dial's
  1744.  *  current setting, and can be changed by the player by typing the
  1745.  *  command "turn dial to number."  By default, the ldesc
  1746.  *  method displays the current setting.
  1747.  */
  1748. class dialItem: fixeditem
  1749.     maxsetting = 10 // it has settings from 1 to this number
  1750.     setting = 1     // the current setting
  1751.     ldesc =
  1752.     {
  1753.         caps(); self.thedesc; " can be turned to settings
  1754.         numbered from 1 to << self.maxsetting >>. It's
  1755.         currently set to << self.setting >>. ";
  1756.     }
  1757.     verDoTurn( actor ) = {}
  1758.     doTurn( actor ) =
  1759.     {
  1760.         askio( toPrep );
  1761.     }
  1762.     verDoTurnTo( actor, io ) = {}
  1763.     doTurnTo( actor, io ) =
  1764.     {
  1765.         if ( io = numObj )
  1766.         {
  1767.             if ( numObj.value < 1 or numObj.value > self.maxsetting )
  1768.             {
  1769.                 "There's no such setting! ";
  1770.             }
  1771.             else if ( numObj.value <> self.setting )
  1772.             {
  1773.                 self.setting := numObj.value;
  1774.                 "Okay, it's now turned to "; say( self.setting ); ". ";
  1775.             }
  1776.             else
  1777.             {
  1778.                 "It's already set to "; say( self.setting ); "! ";
  1779.             }
  1780.         }
  1781.         else
  1782.         {
  1783.             "I don't know how to turn "; self.thedesc;
  1784.             " to that. ";
  1785.         }
  1786.     }
  1787. ;
  1788.  
  1789. /*
  1790.  *  switchItem: fixeditem
  1791.  *
  1792.  *  This is a class for things that can be turned on and off by the
  1793.  *  player.  The only special property is isActive, which is nil
  1794.  *  if the switch is turned off and true when turned on.  The object
  1795.  *  accepts the commands "turn it on" and "turn it off,'' as well as
  1796.  *  synonymous constructions, and updates isActive accordingly.
  1797.  */
  1798. class switchItem: fixeditem
  1799.     verDoSwitch( actor ) = {}
  1800.     doSwitch( actor ) =
  1801.     {
  1802.         self.isActive := not self.isActive;
  1803.         "Okay, "; self.thedesc; " is now switched ";
  1804.         if ( self.isActive ) "on"; else "off";
  1805.         ". ";
  1806.     }
  1807.     verDoTurnon( actor ) =
  1808.     {
  1809.         /*
  1810.            You can't turn on something in the dark unless you're carrying
  1811.            it.  You also can't turn something on if it's already on.
  1812.         */
  1813.     if (not actor.location.islit and not actor.isCarrying(self))
  1814.         "It's pitch black.";
  1815.         else if ( self.isActive )
  1816.             "It's already turned on! ";
  1817.     }
  1818.     doTurnon( actor ) =
  1819.     {
  1820.         self.isActive := true;
  1821.         "Okay, it's now turned on. ";
  1822.     }
  1823.     verDoTurnoff( actor ) =
  1824.     {
  1825.         if ( not self.isActive ) "It's already turned off! ";
  1826.     }
  1827.     doTurnoff( actor ) =
  1828.     {
  1829.         self.isActive := nil;
  1830.         "Okay, it's now turned off. ";
  1831.     }
  1832. ;
  1833.  
  1834. /*
  1835.  *  room: thing
  1836.  *
  1837.  *  A location in the game.  By default, the islit property is
  1838.  *  true, which means that the room is lit (no light source is
  1839.  *  needed while in the room).  You should create a darkroom
  1840.  *  object rather than a room with islit set to nil if you
  1841.  *  want a dark room, because other methods are affected as well.
  1842.  *  The isseen property records whether the player has entered
  1843.  *  the room before; initially it's nil, and is set to true
  1844.  *  the first time the player enters.  The roomAction(actor,
  1845.  *  verb, directObject, preposition, indirectObject) method is
  1846.  *  activated for each player command; by default, all it does is
  1847.  *  call the room's location's roomAction method if the room
  1848.  *  is inside another room.  The lookAround(verbosity)
  1849.  *  method displays the room's description for a given verbosity
  1850.  *  level; true means a full description, nil means only
  1851.  *  the short description (just the room name plus a list of the
  1852.  *  objects present).  roomDrop(object) is called when
  1853.  *  an object is dropped within the room; normally, it just moves
  1854.  *  the object to the room and displays "Dropped."  The firstseen
  1855.  *  method is called when isseen is about to be set true
  1856.  *  for the first time (i.e., when the player first sees the room);
  1857.  *  by default, this routine does nothing, but it's a convenient
  1858.  *  place to put any special code you want to execute when a room
  1859.  *  is first entered.  The firstseen method is called after
  1860.  *  the room's description is displayed.
  1861.  */
  1862. class room: thing
  1863.     /*
  1864.      *   'reachable' is the list of explicitly reachable objects, over and
  1865.      *   above the objects that are here.  This is mostly used in nested
  1866.      *   rooms to make objects in the containing room accessible.  Most
  1867.      *   normal rooms will leave this as an empty list.
  1868.      */
  1869.     reachable = []
  1870.     
  1871.     /*
  1872.      *   roomCheck is true if the verb is valid in the room.  This
  1873.      *   is a first pass; generally, its only function is to disallow
  1874.      *   certain commands in a dark room.
  1875.      */
  1876.     roomCheck( v ) = { return( true ); }
  1877.     islit = true            // rooms are lit unless otherwise specified
  1878.     isseen = nil            // room has not been seen yet
  1879.     enterRoom( actor ) =    // sent to room as actor is entering it
  1880.     {
  1881.         self.lookAround(( not self.isseen ) or global.verbose );
  1882.         if ( self.islit )
  1883.     {
  1884.         if (not self.isseen) self.firstseen;
  1885.         self.isseen := true;
  1886.     }
  1887.     }
  1888.     roomAction( a, v, d, p, i ) =
  1889.     {
  1890.         if ( self.location ) self.location.roomAction( a, v, d, p, i );
  1891.     }
  1892.  
  1893.     /*
  1894.      *   Whenever a normal object (i.e., one that does not override the
  1895.      *   default doDrop provided by 'thing') is dropped, the actor's
  1896.      *   location is sent roomDrop(object being dropped).  By default, 
  1897.      *   we move the object into this room.
  1898.      */
  1899.     roomDrop( obj ) =
  1900.     {
  1901.         "Dropped. ";
  1902.     obj.moveInto( self );
  1903.     }
  1904.  
  1905.     /*
  1906.      *   Whenever an actor leaves this room, we run through the leaveList.
  1907.      *   This is a list of objects that have registered themselves with us
  1908.      *   via addLeaveList().  For each object in the leaveList, we send
  1909.      *   a "leaving" message, with the actor as the parameter.  It should
  1910.      *   return true if it wants to be removed from the leaveList, nil
  1911.      *   if it wants to stay.
  1912.      */
  1913.     leaveList = []
  1914.     addLeaveList( obj ) =
  1915.     {
  1916.         self.leaveList := self.leaveList + obj;
  1917.     }
  1918.     leaveRoom( actor ) =
  1919.     {
  1920.         local tmplist, thisobj, i, tot;
  1921.  
  1922.         tmplist := self.leaveList;
  1923.     tot := length( tmplist );
  1924.     i := 1;
  1925.         while ( i <= tot )
  1926.         {
  1927.         thisobj := tmplist[i];
  1928.             if ( thisobj.leaving( actor ))
  1929.                 self.leaveList := self.leaveList - thisobj;
  1930.             i := i + 1;
  1931.         }
  1932.     }
  1933.     /*
  1934.      *   lookAround describes the room.  If verbosity is true, the full
  1935.      *   description is given, otherwise an abbreviated description (without
  1936.      *   the room's ldesc) is displayed.
  1937.      */
  1938.     nrmLkAround( verbosity ) =      // lookAround without location status
  1939.     {
  1940.         local l, cur, i, tot;
  1941.  
  1942.         if ( verbosity )
  1943.         {
  1944.             "\n\t"; self.ldesc;
  1945.  
  1946.             l := self.contents;
  1947.         tot := length( l );
  1948.         i := 1;
  1949.             while ( i <= tot )
  1950.             {
  1951.             cur := l[i];
  1952.                 if ( cur.isfixed ) cur.heredesc;
  1953.                 i := i + 1;
  1954.             }
  1955.         }
  1956.         "\n\t";
  1957.         if (itemcnt( self.contents ))
  1958.         {
  1959.             "You see "; listcont( self ); " here. ";
  1960.         }
  1961.         listcontcont( self ); "\n";
  1962.  
  1963.         l := self.contents;
  1964.     tot := length( l );
  1965.     i := 1;
  1966.         while ( i <= tot )
  1967.         {
  1968.         cur := l[i];
  1969.             if ( cur.isactor )
  1970.             {
  1971.                 if ( cur <> Me )
  1972.                 {
  1973.                     "\n\t";
  1974.                     cur.actorDesc;
  1975.                 }
  1976.             }
  1977.             i := i + 1;
  1978.         }
  1979.     }
  1980.     statusLine =
  1981.     {
  1982.         self.sdesc; "\n\t";
  1983.     }
  1984.     lookAround( verbosity ) =
  1985.     {
  1986.         self.statusLine;
  1987.         self.nrmLkAround( verbosity );
  1988.     }
  1989.     
  1990.     /*
  1991.      *   Direction handlers.  The directions are all set up to
  1992.      *   the default, which is no travel allowed.  To make travel
  1993.      *   possible in a direction, just assign a room to the direction
  1994.      *   property.
  1995.      */
  1996.     north = { return( self.noexit ); }
  1997.     south = { return( self.noexit ); }
  1998.     east  = { return( self.noexit ); }
  1999.     west  = { return( self.noexit ); }
  2000.     up    = { return( self.noexit ); }
  2001.     down  = { return( self.noexit ); }
  2002.     ne    = { return( self.noexit ); }
  2003.     nw    = { return( self.noexit ); }
  2004.     se    = { return( self.noexit ); }
  2005.     sw    = { return( self.noexit ); }
  2006.     in    = { return( self.noexit ); }
  2007.     out   = { return( self.noexit ); }
  2008.     
  2009.     /*
  2010.      *   noexit displays a message when the player attempts to travel
  2011.      *   in a direction in which travel is not possible.
  2012.      */
  2013.     noexit = { "%You% can't go that way. "; return( nil ); }
  2014. ;
  2015.  
  2016. /*
  2017.  *  darkroom: room
  2018.  *
  2019.  *  A dark room.  The player must have some object that can act as a
  2020.  *  light source in order to move about and perform most operations
  2021.  *  while in this room.  Note that the room's lights can be turned
  2022.  *  on by setting the room's lightsOn property to true;
  2023.  *  do this instead of setting islit, because islit is
  2024.  *  a method which checks for the presence of a light source.
  2025.  */
  2026. class darkroom: room        // An enterable area which might be dark
  2027.     islit =                 // true ONLY if something is lighting the room
  2028.     {
  2029.         local rem, cur, tot, i;
  2030.  
  2031.     if ( self.lightsOn ) return( true );
  2032.  
  2033.     rem := global.lamplist;
  2034.     tot := length( rem );
  2035.     i := 1;
  2036.     while ( i <= tot )
  2037.     {
  2038.         cur := rem[i];
  2039.         if ( cur.isIn( self ) and cur.islit ) return( true );
  2040.         i := i + 1;
  2041.     }
  2042.     return( nil );
  2043.     }
  2044.     roomAction( actor, v, dobj, prep, io ) =
  2045.     {
  2046.         if ( not self.islit and not v.isDarkVerb )
  2047.     {
  2048.         "%You% can't see a thing. ";
  2049.         exit;
  2050.     }
  2051.     else pass roomAction;
  2052.     }
  2053.     statusLine =
  2054.     {
  2055.         if ( self.islit ) pass statusLine;
  2056.     else "In the dark.";
  2057.     }
  2058.     lookAround( verbosity ) =
  2059.     {
  2060.         if ( self.islit ) pass lookAround;
  2061.     else "It's pitch black. ";
  2062.     }
  2063.     noexit =
  2064.     {
  2065.         if ( self.islit ) pass noexit;
  2066.     else
  2067.     {
  2068.         darkTravel();
  2069.         return( nil );
  2070.     }
  2071.     }
  2072.     roomCheck( v ) =
  2073.     {
  2074.         if ( self.islit or v.isDarkVerb ) return( true );
  2075.     else
  2076.     {
  2077.         "It's pitch black.\n";
  2078.         return( nil );
  2079.     }
  2080.     }
  2081. ;
  2082.  
  2083. /*
  2084.  *  theFloor is a special item that appears in every room (hence
  2085.  *  the non-standard location property).  This object is included
  2086.  *  mostly for completeness, so that the player can refer to the
  2087.  *  floor; otherwise, it doesn't do much.  Dropping an item on the
  2088.  *  floor, for example, moves it to the current room.
  2089.  */
  2090. theFloor: beditem, floatingItem
  2091.     noun = 'floor' 'ground'
  2092.     sdesc = "ground"
  2093.     adesc = "the ground"
  2094.     statusPrep = "on"
  2095.     outOfPrep = "off of"
  2096.     location =
  2097.     {
  2098.         if ( Me.location = self )
  2099.             return( self.sitloc );
  2100.         else
  2101.             return( Me.location );
  2102.     }
  2103.     locationOK = true        // suppress warning about location being a method
  2104.     doSiton( actor ) =
  2105.     {
  2106.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  2107.         self.sitloc := actor.location;
  2108.         actor.moveInto( self );
  2109.     }
  2110.     doLieon( actor ) =
  2111.     {
  2112.         self.doSiton( actor );
  2113.     }
  2114.     ioPutOn( actor, dobj ) =
  2115.     {
  2116.         dobj.doDrop( actor );
  2117.     }
  2118.     ioPutIn( actor, dobj ) =
  2119.     {
  2120.         dobj.doDrop( actor );
  2121.     }
  2122. ;
  2123.  
  2124. /*
  2125.  *  Actor: fixeditem, movableActor
  2126.  *
  2127.  *  A character in the game.  The maxweight property specifies
  2128.  *  the maximum weight that the character can carry, and the maxbulk
  2129.  *  property specifies the maximum bulk the character can carry.  The
  2130.  *  actorAction(verb, directObject, preposition, indirectObject)
  2131.  *  method specifies what happens when the actor is given a command by
  2132.  *  the player; by default, the actor ignores the command and displays
  2133.  *  a message to this effect.  The isCarrying(object)
  2134.  *  method returns true if the object is being carried by
  2135.  *  the actor.  The actorDesc method displays a message when the
  2136.  *  actor is in the current room; this message is displayed along with
  2137.  *  a room's description when the room is entered or examined.  The
  2138.  *  verGrab(object) method is called when someone tries to
  2139.  *  take an object the actor is carrying; by default, an actor won't
  2140.  *  let other characters take its possessions.
  2141.  *  
  2142.  *  If you want the player to be able to follow the actor when it
  2143.  *  leaves the room, you should define a follower object to shadow
  2144.  *  the character, and set the actor's myfollower property to
  2145.  *  the follower object.  The follower is then automatically
  2146.  *  moved around just behind the actor by the actor's moveInto
  2147.  *  method.
  2148.  *  
  2149.  *  The isHim property should return true if the actor can
  2150.  *  be referred to by the player as "him," and likewise isHer
  2151.  *  should be set to true if the actor can be referred to as "her."
  2152.  *  Note that both or neither can be set; if neither is set, the actor
  2153.  *  can only be referred to as "it," and if both are set, any of "him,''
  2154.  *  "her," or "it'' will be accepted.
  2155.  */
  2156. class Actor: fixeditem, movableActor
  2157. ;
  2158.  
  2159. /*
  2160.  *  movableActor: qcontainer
  2161.  *
  2162.  *  Just like an Actor object, except that the player can
  2163.  *  manipulate the actor like an ordinary item.  Useful for certain
  2164.  *  types of actors, such as small animals.
  2165.  */
  2166. class movableActor: qcontainer // A character in the game
  2167.     isListed = nil          // described separately from room's contents
  2168.     weight = 10             // actors are pretty heavy
  2169.     bulk = 10               // and pretty bulky
  2170.     maxweight = 50          // Weight that can be carried at once
  2171.     maxbulk = 20            // Number of objects that can be carried at once
  2172.     isactor = true          // flag that this is an actor
  2173.     roomCheck( v ) = { return( self.location.roomCheck(v)); }
  2174.     actorAction( v, d, p, i ) =
  2175.     {
  2176.         caps(); self.thedesc; " doesn't appear interested. ";
  2177.         exit;
  2178.     }
  2179.     isCarrying( obj ) = { return( obj.isIn( self )); }
  2180.     actorDesc =
  2181.     {
  2182.         caps(); self.adesc; " is here. ";
  2183.     }
  2184.     verGrab( item ) =
  2185.     {
  2186.         caps(); self.thedesc; " is carrying "; item.thedesc;
  2187.         " and won't let %youm% have it. ";
  2188.     }
  2189.     verDoFollow( actor ) =
  2190.     {
  2191.         "But "; self.thedesc; " is right here! ";
  2192.     }
  2193.     moveInto( obj ) =
  2194.     {
  2195.         if ( self.myfollower ) self.myfollower.moveInto( self.location );
  2196.     pass moveInto;
  2197.     }
  2198.     // these properties are for the format strings
  2199.     fmtYou = "he"
  2200.     fmtYour = "his"
  2201.     fmtYoure = "he's"
  2202.     fmtYoum = "him"
  2203.     fmtYouve = "he's"
  2204.     fmtS = "s"
  2205.     fmtEs = "es"
  2206.     fmtHave = "has"
  2207.     fmtDo = "does"
  2208.     fmtAre = "is"
  2209.     fmtMe = { self.thedesc; }
  2210.     askWord(word, lst) = { return(nil); }
  2211.     verDoAskAbout(actor, iobj) = {}
  2212.     doAskAbout(actor, iobj) =
  2213.     {
  2214.     local lst, i, tot;
  2215.  
  2216.     lst := objwords(2);       // get actual words asked about
  2217.     tot := length(lst);
  2218.     if ((tot = 1 and (find(['it' 'them' 'him' 'her'], lst[1]) <> nil))
  2219.         or tot = 0)
  2220.     {
  2221.         "\"Could you be more specific?\"";
  2222.         return;
  2223.     }
  2224.  
  2225.     // try to find a response for each word
  2226.     for (i := 1 ; i <= tot ; ++i)
  2227.     {
  2228.         if (self.askWord(lst[i], lst))
  2229.             return;
  2230.         }
  2231.  
  2232.     // didn't find anything to talk about
  2233.     self.disavow;
  2234.     }
  2235.     disavow = "\"I don't know much about that.\""
  2236.     verIoPutIn(actor) =
  2237.     {
  2238.         "If you want to give that to << thedesc >>, just say so.";
  2239.     }
  2240.     verIoGiveTo(actor) =
  2241.     {
  2242.     if (actor = self)
  2243.         "That wouldn't accomplish anything!";
  2244.     }
  2245.     ioGiveTo(actor, dobj) =
  2246.     {
  2247.     "\^<<self.thedesc>> rejects the offer.";
  2248.     }
  2249.  
  2250.     // move to a new location, notifying player of coming and going
  2251.     travelTo(room) =
  2252.     {
  2253.     /* do nothing if going nowhere */
  2254.     if (room = nil) return;
  2255.     
  2256.         /* notify player if leaving player's location (and it's not dark) */
  2257.         if (self.location = Me.location and self.location.islit)
  2258.             self.sayLeaving;
  2259.  
  2260.         /* move to my new location */
  2261.         self.moveInto(room);
  2262.  
  2263.         /* notify player if arriving at player's location */
  2264.         if (self.location = Me.location and self.location.islit)
  2265.             self.sayArriving;
  2266.     }
  2267.  
  2268.     // sayLeaving and sayArriving announce the actor's departure and arrival
  2269.     // in the same room as the player.
  2270.     sayLeaving = "\n\t\^<<self.thedesc>> leaves the area."
  2271.     sayArriving = "\n\t\^<<self.thedesc>> enters the area."
  2272.  
  2273.     // this should be used as an actor when ambiguous
  2274.     preferredActor = true
  2275. ;
  2276.  
  2277. /*
  2278.  *  follower: Actor
  2279.  *
  2280.  *  This is a special object that can "shadow" the movements of a
  2281.  *  character as it moves from room to room.  The purpose of a follower
  2282.  *  is to allow the player to follow an actor as it leaves a room by
  2283.  *  typing a "follow" command.  Each actor that is to be followed must
  2284.  *  have its own follower object.  The follower object should
  2285.  *  define all of the same vocabulary words (nouns and adjectives) as the
  2286.  *  actual actor to which it refers.  The follower must also
  2287.  *  define the myactor property to be the Actor object that
  2288.  *  the follower follows.  The follower will always stay
  2289.  *  one room behind the character it follows; no commands are effective
  2290.  *  with a follower except for "follow."
  2291.  */
  2292. class follower: Actor
  2293.     sdesc = { self.myactor.sdesc; }
  2294.     isfollower = true
  2295.     ldesc = { caps(); self.thedesc; " is no longer here. "; }
  2296.     actorAction( v, d, p, i ) = { self.ldesc; exit; }
  2297.     actorDesc = {}
  2298.     myactor = nil   // set to the Actor to be followed
  2299.     verDoFollow( actor ) = {}
  2300.     doFollow( actor ) =
  2301.     {
  2302.         actor.travelTo( self.myactor.location );
  2303.     }
  2304.     dobjGen(a, v, i, p) =
  2305.     {
  2306.         if (v <> followVerb)
  2307.     {
  2308.         "\^<< self.myactor.thedesc >> is no longer here.";
  2309.         exit;
  2310.     }
  2311.     }
  2312.     iobjGen(a, v, d, p) =
  2313.     {
  2314.         "\^<< self.myactor.thedesc >> is no longer here.";
  2315.     exit;
  2316.     }
  2317. ;
  2318.  
  2319. /*
  2320.  *  basicMe: Actor
  2321.  *
  2322.  *  A default implementation of the Me object, which is the
  2323.  *  player character.  adv.t defines basicMe instead of
  2324.  *  Me to allow your game to override parts of the default
  2325.  *  implementation while still using the rest, and without changing
  2326.  *  adv.t itself.  To use basicMe unchanged as your player
  2327.  *  character, include this in your game:  "Me: basicMe;".
  2328.  *  
  2329.  *  The basicMe object defines all of the methods and properties
  2330.  *  required for an actor, with appropriate values for the player
  2331.  *  character.  The nouns "me" and "myself'' are defined ("I''
  2332.  *  is not defined, because it conflicts with the "inventory"
  2333.  *  command's minimal abbreviation of "i" in certain circumstances,
  2334.  *  and is generally not compatible with the syntax of most player
  2335.  *  commands anyway).  The sdesc is "you"; the thedesc
  2336.  *  and adesc are "yourself," which is appropriate for most
  2337.  *  contexts.  The maxbulk and maxweight properties are
  2338.  *  set to 10 each; a more sophisticated Me might include the
  2339.  *  player's state of health in determining the maxweight and
  2340.  *  maxbulk properties.
  2341.  */
  2342. class basicMe: Actor, floatingItem
  2343.     roomCheck( v ) = { return( self.location.roomCheck( v )); }
  2344.     noun = 'me' 'myself'
  2345.     sdesc = "you"
  2346.     thedesc = "yourself"
  2347.     adesc = "yourself"
  2348.     ldesc = "You look about the same as always. "
  2349.     maxweight = 10
  2350.     maxbulk = 10
  2351.     verDoFollow( actor ) =
  2352.     {
  2353.         if ( actor = self ) "You can't follow yourself! ";
  2354.     }
  2355.     actorAction( verb, dobj, prep, iobj ) = 
  2356.     {
  2357.     }
  2358.     travelTo( room ) =
  2359.     {
  2360.         if ( room )
  2361.         {
  2362.         if ( room.isobstacle )
  2363.         {
  2364.             self.travelTo( room.destination );
  2365.         }
  2366.         else if ( not ( self.location.islit or room.islit ))
  2367.         {
  2368.             darkTravel();
  2369.         }
  2370.         else
  2371.         {
  2372.                 if ( self.location ) self.location.leaveRoom( self );
  2373.                 self.location := room;
  2374.                 room.enterRoom( self );
  2375.         }
  2376.         }
  2377.     }
  2378.     moveInto( room ) =
  2379.     {
  2380.         self.location := room;
  2381.     }
  2382.     ioGiveTo(actor, dobj) =
  2383.     {
  2384.     "You accept <<dobj.thedesc>> from <<actor.thedesc>>.";
  2385.     dobj.moveInto(Me);
  2386.     }
  2387.  
  2388.     // these properties are for the format strings
  2389.     fmtYou = "you"
  2390.     fmtYour = "your"
  2391.     fmtYoure = "you're"
  2392.     fmtYoum = "you"
  2393.     fmtYouve = "you've"
  2394.     fmtS = ""
  2395.     fmtEs = ""
  2396.     fmtHave = "have"
  2397.     fmtDo = "do"
  2398.     fmtAre = "are"
  2399.     fmtMe = "me"
  2400. ;
  2401.  
  2402. /*
  2403.  *  decoration: fixeditem
  2404.  *
  2405.  *  An item that doesn't have any function in the game, apart from
  2406.  *  having been mentioned in the room description.  These items
  2407.  *  are immovable and can't be manipulated in any way, but can be
  2408.  *  referred to and inspected.  Liberal use of decoration items
  2409.  *  can improve a game's playability by helping the parser recognize
  2410.  *  all the words the game uses in its descriptions of rooms.
  2411.  */
  2412. class decoration: fixeditem
  2413.     ldesc = "That's not important."
  2414.     dobjGen(a, v, i, p) =
  2415.     {
  2416.         if (v <> inspectVerb)
  2417.     {
  2418.         "\^<<self.thedesc>> isn't important.";
  2419.         exit;
  2420.     }
  2421.     }
  2422.     iobjGen(a, v, d, p) =
  2423.     {
  2424.         "\^<<self.thedesc>> isn't important.";
  2425.     exit;
  2426.     }
  2427. ;
  2428.  
  2429. /*
  2430.  *  distantItem: fixeditem
  2431.  *
  2432.  *  This is an item that is too far away to manipulate, but can be seen.
  2433.  *  The class uses dobjGen and iobjGen to prevent any verbs from being
  2434.  *  used on the object apart from inspectVerb; using any other verb results
  2435.  *  in the message "It's too far away."  Instances of this class should
  2436.  *  provide the normal item properties:  sdesc, ldesc, location,
  2437.  *  and vocabulary.
  2438.  */
  2439. class distantItem: fixeditem
  2440.     dobjGen(a, v, i, p) =
  2441.     {
  2442.         if (v <> inspectVerb)
  2443.         {
  2444.             "It's too far away.";
  2445.             exit;
  2446.         }
  2447.     }
  2448.     iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); }
  2449. ;
  2450.  
  2451. /*
  2452.  *  buttonitem: fixeditem
  2453.  *
  2454.  *  A button (the type you push).  The individual button's action method
  2455.  *  doPush(actor), which must be specified in
  2456.  *  the button, carries out the function of the button.  Note that
  2457.  *  all buttons have the noun "button" defined.
  2458.  */
  2459. class buttonitem: fixeditem
  2460.     noun = 'button'
  2461.     plural = 'buttons'
  2462.     verDoPush( actor ) = {}
  2463. ;
  2464.  
  2465. /*
  2466.  *  clothingItem: item
  2467.  *
  2468.  *  Something that can be worn.  By default, the only thing that
  2469.  *  happens when the item is worn is that its isworn property
  2470.  *  is set to true.  If you want more to happen, override the
  2471.  *  doWear(actor) property.  Note that, when a clothingItem
  2472.  *  is being worn, certain operations will cause it to be removed (for
  2473.  *  example, dropping it causes it to be removed).  If you want
  2474.  *  something else to happen, override the checkDrop method;
  2475.  *  if you want to disallow such actions while the object is worn,
  2476.  *  use an exit statement in the checkDrop method.
  2477.  */
  2478. class clothingItem: item
  2479.     checkDrop =
  2480.     {
  2481.         if ( self.isworn )
  2482.     {
  2483.         "(Taking off "; self.thedesc; " first)\n";
  2484.         self.isworn := nil;
  2485.     }
  2486.     }
  2487.     doDrop( actor ) =
  2488.     {
  2489.         self.checkDrop;
  2490.     pass doDrop;
  2491.     }
  2492.     doPutIn( actor, io ) =
  2493.     {
  2494.         self.checkDrop;
  2495.     pass doPutIn;
  2496.     }
  2497.     doPutOn( actor, io ) =
  2498.     {
  2499.         self.checkDrop;
  2500.     pass doPutOn;
  2501.     }
  2502.     doGiveTo( actor, io ) =
  2503.     {
  2504.         self.checkDrop;
  2505.     pass doGiveTo;
  2506.     }
  2507.     doThrowAt( actor, io ) =
  2508.     {
  2509.         self.checkDrop;
  2510.     pass doThrowAt;
  2511.     }
  2512.     doThrowTo( actor, io ) =
  2513.     {
  2514.         self.checkDrop;
  2515.     pass doThrowTo;
  2516.     }
  2517.     doThrow( actor ) =
  2518.     {
  2519.         self.checkDrop;
  2520.     pass doThrow;
  2521.     }
  2522.     moveInto( obj ) =
  2523.     {
  2524.         /*
  2525.      *   Catch any other movements with moveInto; this won't stop the
  2526.      *   movement from happening, but it will prevent any anamolous
  2527.      *   consequences caused by the object moving but still being worn.
  2528.      */
  2529.         self.isworn := nil;
  2530.     pass moveInto;
  2531.     }
  2532.     verDoWear( actor ) =
  2533.     {
  2534.         if ( self.isworn )
  2535.         {
  2536.             "%You're% already wearing "; self.thedesc; "! ";
  2537.         }
  2538.         else if ( not actor.isCarrying( self ))
  2539.         {
  2540.             "%You% %do%n't have "; self.thedesc; ". ";
  2541.         }
  2542.     }
  2543.     doWear( actor ) =
  2544.     {
  2545.         "Okay, %you're% now wearing "; self.thedesc; ". ";
  2546.         self.isworn := true;
  2547.     }
  2548.     verDoUnwear( actor ) =
  2549.     {
  2550.         if ( not self.isworn )
  2551.         {
  2552.             "%You're% not wearing "; self.thedesc; ". ";
  2553.         }
  2554.     }
  2555.     verDoTake(actor) =
  2556.     {
  2557.         if (self.isworn) self.verDoUnwear(actor);
  2558.     else pass verDoTake;
  2559.     }
  2560.     doTake(actor) =
  2561.     {
  2562.         if (self.isworn) self.doUnwear(actor);
  2563.     else pass doTake;
  2564.     }
  2565.     doUnwear( actor ) =
  2566.     {
  2567.         "Okay, %you're% no longer wearing "; self.thedesc; ". ";
  2568.         self.isworn := nil;
  2569.     }
  2570.     doSynonym('Unwear') = 'Unboard'
  2571. ;
  2572.  
  2573. /*
  2574.  *  obstacle: object
  2575.  *
  2576.  *  An obstacle is used in place of a room for a direction
  2577.  *  property.  The destination property specifies the room that
  2578.  *  is reached if the obstacle is successfully negotiated; when the
  2579.  *  obstacle is not successfully negotiated, destination should
  2580.  *  display an appropriate message and return nil.
  2581.  */
  2582. class obstacle: object
  2583.     isobstacle = true
  2584. ;
  2585.  
  2586. /*
  2587.  *  doorway: fixeditem, obstacle
  2588.  *
  2589.  *  A doorway is an obstacle that impedes progress when it is closed.
  2590.  *  When the door is open (isopen is true), the user ends up in
  2591.  *  the room specified in the doordest property upon going through
  2592.  *  the door.  Since a doorway is an obstacle, use the door object for
  2593.  *  a direction property of the room containing the door.
  2594.  *  
  2595.  *  If noAutoOpen is not set to true, the door will automatically
  2596.  *  be opened when the player tries to walk through the door, unless the
  2597.  *  door is locked (islocked = true).  If the door is locked,
  2598.  *  it can be unlocked simply by typing "unlock door", unless the
  2599.  *  mykey property is set, in which case the object specified in
  2600.  *  mykey must be used to unlock the door.  Note that the door can
  2601.  *  only be relocked by the player under the circumstances that allow
  2602.  *  unlocking, plus the property islockable must be set to true.
  2603.  *  By default, the door is closed; set isopen to true if the door
  2604.  *  is to start out open (and be sure to open the other side as well).
  2605.  *  
  2606.  *  otherside specifies the corresponding doorway object in the
  2607.  *  destination room (doordest), if any.  If otherside is
  2608.  *  specified, its isopen and islocked properties will be
  2609.  *  kept in sync automatically.
  2610.  */
  2611. class doorway: fixeditem, obstacle
  2612.     isdoor = true           // Item can be opened and closed
  2613.     destination =
  2614.     {
  2615.         if ( self.isopen ) return( self.doordest );
  2616.     else if ( not self.islocked and not self.noAutoOpen )
  2617.     {
  2618.         self.isopen := true;
  2619.         if ( self.otherside ) self.otherside.isopen := true;
  2620.         "(Opening << self.thedesc >>)\n";
  2621.         return( self.doordest );
  2622.     }
  2623.     else
  2624.     {
  2625.         "%You%'ll have to open << self.thedesc >> first. ";
  2626.         setit( self );
  2627.         return( nil );
  2628.     }
  2629.     }
  2630.     verDoOpen( actor ) =
  2631.     {
  2632.         if ( self.isopen ) "It's already open. ";
  2633.     else if ( self.islocked ) "It's locked. ";
  2634.     }
  2635.     doOpen( actor ) =
  2636.     {
  2637.         "Opened. ";
  2638.     self.isopen := true;
  2639.     if ( self.otherside ) self.otherside.isopen := true;
  2640.     }
  2641.     verDoClose( actor ) =
  2642.     {
  2643.         if ( not self.isopen ) "It's already closed. ";
  2644.     }
  2645.     doClose( actor ) =
  2646.     {
  2647.         "Closed. ";
  2648.     self.isopen := nil;
  2649.     if ( self.otherside ) self.otherside.isopen := nil;
  2650.     }
  2651.     verDoLock( actor ) =
  2652.     {
  2653.         if ( self.islocked ) "It's already locked! ";
  2654.     else if ( not self.islockable ) "It can't be locked. ";
  2655.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2656.     }
  2657.     doLock( actor ) =
  2658.     {
  2659.         if ( self.mykey = nil )
  2660.     {
  2661.         "Locked. ";
  2662.         self.islocked := true;
  2663.         if ( self.otherside ) self.otherside.islocked := true;
  2664.     }
  2665.     else
  2666.             askio( withPrep );
  2667.     }
  2668.     verDoUnlock( actor ) =
  2669.     {
  2670.         if ( not self.islocked ) "It's not locked! ";
  2671.     }
  2672.     doUnlock( actor ) =
  2673.     {
  2674.         if ( self.mykey = nil )
  2675.     {
  2676.         "Unlocked. ";
  2677.         self.islocked := nil;
  2678.         if ( self.otherside ) self.otherside.islocked := nil;
  2679.     }
  2680.     else
  2681.         askio( withPrep );
  2682.     }
  2683.     verDoLockWith( actor, io ) =
  2684.     {
  2685.         if ( self.islocked ) "It's already locked. ";
  2686.     else if ( not self.islockable ) "It can't be locked. ";
  2687.     else if ( self.mykey = nil )
  2688.         "%You% %do%n't need anything to lock it. ";
  2689.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2690.     }
  2691.     doLockWith( actor, io ) =
  2692.     {
  2693.         if ( io = self.mykey )
  2694.     {
  2695.         "Locked. ";
  2696.         self.islocked := true;
  2697.         if ( self.otherside ) self.otherside.islocked := true;
  2698.     }
  2699.     else "It doesn't fit the lock. ";
  2700.     }
  2701.     verDoUnlockWith( actor, io ) =
  2702.     {
  2703.         if ( not self.islocked ) "It's not locked! ";
  2704.     else if ( self.mykey = nil )
  2705.         "%You% %do%n't need anything to unlock it. ";
  2706.     }
  2707.     doUnlockWith( actor, io ) =
  2708.     {
  2709.         if ( io = self.mykey )
  2710.     {
  2711.         "Unlocked. ";
  2712.         self.islocked := nil;
  2713.         if ( self.otherside ) self.otherside.islocked := nil;
  2714.     }
  2715.     else "It doesn't fit the lock. ";
  2716.     }
  2717.     ldesc =
  2718.     {
  2719.     if ( self.isopen ) "It's open. ";
  2720.     else
  2721.     {
  2722.         if ( self.islocked ) "It's closed and locked. ";
  2723.         else "It's closed. ";
  2724.     }
  2725.     }
  2726. ;
  2727.  
  2728. /*
  2729.  *  lockableDoorway: doorway
  2730.  *
  2731.  *  This is just a normal doorway with the islockable and
  2732.  *  islocked properties set to true.  Fill in the other
  2733.  *  properties (otherside and doordest) as usual.  If
  2734.  *  the door has a key, set property mykey to the key object.
  2735.  */
  2736. class lockableDoorway: doorway
  2737.     islockable = true
  2738.     islocked = true
  2739. ;
  2740.  
  2741. /*
  2742.  *  vehicle: item, nestedroom
  2743.  *
  2744.  *  This is an object that an actor can board.  An actor cannot go
  2745.  *  anywhere while on board a vehicle (except where the vehicle goes);
  2746.  *  the actor must get out first.
  2747.  */
  2748. class vehicle: item, nestedroom
  2749.     reachable = ([] + self)
  2750.     isvehicle = true
  2751.     verDoEnter( actor ) = { self.verDoBoard( actor ); }
  2752.     doEnter( actor ) = { self.doBoard( actor ); }
  2753.     verDoBoard( actor ) =
  2754.     {
  2755.         if ( actor.location = self )
  2756.         {
  2757.             "%You're% already in "; self.thedesc; "! ";
  2758.         }
  2759.     else if (actor.isCarrying(self))
  2760.     {
  2761.         "%You%'ll have to drop <<thedesc>> first!";
  2762.     }
  2763.     }
  2764.     doBoard( actor ) =
  2765.     {
  2766.         "Okay, %you're% now in "; self.thedesc; ". ";
  2767.         actor.moveInto( self );
  2768.     }
  2769.     noexit =
  2770.     {
  2771.         "%You're% not going anywhere until %you% get%s% out of ";
  2772.       self.thedesc; ". ";
  2773.         return( nil );
  2774.     }
  2775.     out = ( self.location )
  2776.     verDoTake(actor) =
  2777.     {
  2778.         if (actor.isIn(self))
  2779.         "%You%'ll have to get <<self.outOfPrep>> <<self.thedesc>> first.";
  2780.     else
  2781.         pass verDoTake;
  2782.     }
  2783.     dobjGen(a, v, i, p) =
  2784.     {
  2785.         if (a.isIn(self) and v <> inspectVerb and v <> getOutVerb
  2786.         and v <> outVerb)
  2787.     {
  2788.         "%You%'ll have to get out of << thedesc >> first.";
  2789.         exit;
  2790.     }
  2791.     }
  2792.     iobjGen(a, v, d, p) =
  2793.     {
  2794.         if (a.isIn(self) and v <> putVerb)
  2795.     {
  2796.         "%You%'ll have to get out of << thedesc >> first.";
  2797.         exit;
  2798.     }
  2799.     }
  2800. ;
  2801.  
  2802. /*
  2803.  *  surface: item
  2804.  *
  2805.  *  Objects can be placed on a surface.  Apart from using the
  2806.  *  preposition "on" rather than "in'' to refer to objects
  2807.  *  contained by the object, a surface is identical to a
  2808.  *  container.  Note: an object cannot be both a
  2809.  *  surface and a container, because there is no
  2810.  *  distinction between the two internally.
  2811.  */
  2812. class surface: item
  2813.     issurface = true        // Item can hold objects on its surface
  2814.     ldesc =
  2815.     {
  2816.         if (itemcnt( self.contents ))
  2817.         {
  2818.             "On "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2819.         }
  2820.         else
  2821.         {
  2822.             "There's nothing on "; self.thedesc; ". ";
  2823.         }
  2824.     }
  2825.     verIoPutOn( actor ) = {}
  2826.     ioPutOn( actor, dobj ) =
  2827.     {
  2828.         dobj.doPutOn( actor, self );
  2829.     }
  2830. ;
  2831.  
  2832. /*
  2833.  *  container: item
  2834.  *
  2835.  *  This object can contain other objects.  The iscontainer property
  2836.  *  is set to true.  The default ldesc displays a list of the
  2837.  *  objects inside the container, if any.  The maxbulk property
  2838.  *  specifies the maximum amount of bulk the container can contain.
  2839.  */
  2840. class container: item
  2841.     maxbulk = 10            // maximum bulk the container can contain
  2842.     isopen = true           // in fact, it can't be closed at all
  2843.     iscontainer = true      // Item can contain other items
  2844.     ldesc =
  2845.     {
  2846.         if ( self.contentsVisible and itemcnt( self.contents ) <> 0 )
  2847.         {
  2848.             "In "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2849.         }
  2850.         else
  2851.         {
  2852.             "There's nothing in "; self.thedesc; ". ";
  2853.         }
  2854.     }
  2855.     verIoPutIn( actor ) =
  2856.     {
  2857.     }
  2858.     ioPutIn( actor, dobj ) =
  2859.     {
  2860.         if (addbulk( self.contents ) + dobj.bulk > self.maxbulk )
  2861.         {
  2862.             "%You% can't fit that in "; self.thedesc; ". ";
  2863.         }
  2864.         else
  2865.         {
  2866.         dobj.doPutIn( actor, self );
  2867.         }
  2868.     }
  2869.     verDoLookin( actor ) = {}
  2870.     doLookin( actor ) =
  2871.     {
  2872.         self.ldesc;
  2873.     }
  2874. ;
  2875.  
  2876. /*
  2877.  *  openable: container
  2878.  *
  2879.  *  A container that can be opened and closed.  The isopenable
  2880.  *  property is set to true.  The default ldesc displays
  2881.  *  the contents of the container if the container is open, otherwise
  2882.  *  a message saying that the object is closed.
  2883.  */
  2884. class openable: container
  2885.     contentsReachable = { return( self.isopen ); }
  2886.     contentsVisible = { return( self.isopen ); }
  2887.     isopenable = true
  2888.     ldesc =
  2889.     {
  2890.         caps(); self.thedesc;
  2891.         if ( self.isopen )
  2892.     {
  2893.         " is open. ";
  2894.         pass ldesc;
  2895.     }
  2896.         else
  2897.     {
  2898.         " is closed. ";
  2899.  
  2900.         /* if it's transparent, list its contents anyway */
  2901.         if (isclass(self, transparentItem)) pass ldesc;
  2902.     }
  2903.     }
  2904.     isopen = true
  2905.     verDoOpen( actor ) =
  2906.     {
  2907.         if ( self.isopen )
  2908.     {
  2909.         caps(); self.thedesc; " is already open! ";
  2910.     }
  2911.     }
  2912.     doOpen( actor ) =
  2913.     {
  2914.         if (itemcnt( self.contents ))
  2915.     {
  2916.         "Opening "; self.thedesc; " reveals "; listcont( self ); ". ";
  2917.     }
  2918.     else "Opened. ";
  2919.     self.isopen := true;
  2920.     }
  2921.     verDoClose( actor ) =
  2922.     {
  2923.         if ( not self.isopen )
  2924.     {
  2925.         caps(); self.thedesc; " is already closed! ";
  2926.     }
  2927.     }
  2928.     doClose( actor ) =
  2929.     {
  2930.         "Closed. ";
  2931.     self.isopen := nil;
  2932.     }
  2933.     verIoPutIn( actor ) =
  2934.     {
  2935.         if ( not self.isopen )
  2936.     {
  2937.         caps(); self.thedesc; " is closed. ";
  2938.     }
  2939.     }
  2940.     verDoLookin( actor ) =
  2941.     {
  2942.         /* we can look in it if either it's open or it's transparent */
  2943.         if (not self.isopen and not isclass(self, transparentItem))
  2944.            "It's closed. ";
  2945.     }
  2946. ;
  2947.  
  2948. /*
  2949.  *  qcontainer: container
  2950.  *
  2951.  *  A "quiet" container:  its contents are not listed when it shows
  2952.  *  up in a room description or inventory list.  The isqcontainer
  2953.  *  property is set to true.
  2954.  */
  2955. class qcontainer: container
  2956.     isqcontainer = true
  2957. ;
  2958.  
  2959. /*
  2960.  *  lockable: openable
  2961.  *
  2962.  *  A container that can be locked and unlocked.  The islocked
  2963.  *  property specifies whether the object can be opened or not.  The
  2964.  *  object can be locked and unlocked without the need for any other
  2965.  *  object; if you want a key to be involved, use a keyedLockable.
  2966.  */
  2967. class lockable: openable
  2968.     verDoOpen( actor ) =
  2969.     {
  2970.         if ( self.islocked )
  2971.         {
  2972.             "It's locked. ";
  2973.         }
  2974.         else pass verDoOpen;
  2975.     }
  2976.     verDoLock( actor ) =
  2977.     {
  2978.         if ( self.islocked )
  2979.         {
  2980.             "It's already locked! ";
  2981.         }
  2982.     }
  2983.     doLock( actor ) =
  2984.     {
  2985.         if ( self.isopen )
  2986.         {
  2987.             "%You%'ll have to close "; self.thedesc; " first. ";
  2988.         }
  2989.         else
  2990.         {
  2991.             "Locked. ";
  2992.             self.islocked := true;
  2993.         }
  2994.     }
  2995.     verDoUnlock( actor ) =
  2996.     {
  2997.         if ( not self.islocked ) "It's not locked! ";
  2998.     }
  2999.     doUnlock( actor ) =
  3000.     {
  3001.         "Unlocked. ";
  3002.         self.islocked := nil;
  3003.     }
  3004.     verDoLockWith( actor, io ) =
  3005.     {
  3006.         if ( self.islocked ) "It's already locked. ";
  3007.     }
  3008.     verDoUnlockWith( actor, io ) =
  3009.     {
  3010.         if ( not self.islocked ) "It's not locked! ";
  3011.     }
  3012. ;
  3013.  
  3014. /*
  3015.  *  keyedLockable: lockable
  3016.  *
  3017.  *  This subclass of lockable allows you to create an object
  3018.  *  that can only be locked and unlocked with a corresponding key.
  3019.  *  Set the property mykey to the keyItem object that can
  3020.  *  lock and unlock the object.
  3021.  */
  3022. class keyedLockable: lockable
  3023.     mykey = nil     // set 'mykey' to the key which locks/unlocks me
  3024.     doLock( actor ) =
  3025.     {
  3026.         askio( withPrep );
  3027.     }
  3028.     doUnlock( actor ) =
  3029.     {
  3030.         askio( withPrep );
  3031.     }
  3032.     doLockWith( actor, io ) =
  3033.     {
  3034.         if ( self.isopen )
  3035.         {
  3036.             "%You% can't lock << self.thedesc >> when it's open. ";
  3037.         }
  3038.         else if ( io = self.mykey )
  3039.         {
  3040.             "Locked. ";
  3041.             self.islocked := true;
  3042.         }
  3043.         else "It doesn't fit the lock. ";
  3044.     }
  3045.     doUnlockWith( actor, io ) =
  3046.     {
  3047.         if ( io = self.mykey )
  3048.         {
  3049.             "Unlocked. ";
  3050.             self.islocked := nil;
  3051.         }
  3052.         else "It doesn't fit the lock. ";
  3053.     }
  3054. ;
  3055.  
  3056. /*
  3057.  *  keyItem: item
  3058.  *
  3059.  *  This is an object that can be used as a key for a keyedLockable
  3060.  *  or lockableDoorway object.  It otherwise behaves as an ordinary item.
  3061.  */
  3062. class keyItem: item
  3063.     verIoUnlockWith( actor ) = {}
  3064.     ioUnlockWith( actor, dobj ) =
  3065.     {
  3066.         dobj.doUnlockWith( actor, self );
  3067.     }
  3068.     verIoLockWith( actor ) = {}
  3069.     ioLockWith( actor, dobj ) =
  3070.     {
  3071.         dobj.doLockWith( actor, self );
  3072.     }
  3073. ;
  3074.  
  3075. /*
  3076.  *  transparentItem: item
  3077.  *
  3078.  *  An object whose contents are visible, even when the object is
  3079.  *  closed.  Whether the contents are reachable is decided in the
  3080.  *  normal fashion.  This class is useful for items such as glass
  3081.  *  bottles, whose contents can be seen when the bottle is closed
  3082.  *  but cannot be reached.
  3083.  */
  3084. class transparentItem: item
  3085.     contentsVisible = { return( true ); }
  3086.     ldesc =
  3087.     {
  3088.         if (self.contentsVisible and itemcnt(self.contents) <> 0)
  3089.         {
  3090.             "In "; self.thedesc; " %you% see%s% "; listcont(self); ". ";
  3091.         }
  3092.         else
  3093.         {
  3094.             "There's nothing in "; self.thedesc; ". ";
  3095.         }
  3096.     }
  3097.     verGrab( obj ) =
  3098.     {
  3099.         if ( self.isopenable and not self.isopen )
  3100.             "%You% will have to open << self.thedesc >> first. ";
  3101.     }
  3102.     doOpen( actor ) =
  3103.     {
  3104.         self.isopen := true;
  3105.         "Opened. ";
  3106.     }
  3107.     verDoLookin(actor) = {}
  3108.     doLookin(actor) = { self.ldesc; }
  3109. ;
  3110.  
  3111. /*
  3112.  *  basicNumObj: object
  3113.  *
  3114.  *  This object provides a default implementation for numObj.
  3115.  *  To use this default unchanged in your game, include in your
  3116.  *  game this line:  "numObj: basicNumObj".
  3117.  */
  3118. class basicNumObj: object   // when a number is used in a player command,
  3119.     value = 0               //  this is set to its value
  3120.     sdesc = "<<value>>"
  3121.     adesc = "a number"
  3122.     thedesc = "the number <<value>>"
  3123.     verDoTypeOn( actor, io ) = {}
  3124.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  3125.     verIoTurnTo( actor ) = {}
  3126.     ioTurnTo( actor, dobj ) = { dobj.doTurnTo( actor, self ); }
  3127. ;
  3128.  
  3129. /*
  3130.  *  basicStrObj: object
  3131.  *
  3132.  *  This object provides a default implementation for strObj.
  3133.  *  To use this default unchanged in your game, include in your
  3134.  *  game this line:  "strObj: basicStrObj".
  3135.  */
  3136. class basicStrObj: object   // when a string is used in a player command,
  3137.     value = ''              //  this is set to its value
  3138.     sdesc = "\"<<value>>\""
  3139.     adesc = "\"<<value>>\""
  3140.     thedesc = "\"<<value>>\""
  3141.     verDoTypeOn( actor, io ) = {}
  3142.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  3143.     doSynonym('TypeOn') = 'EnterOn' 'EnterIn' 'EnterWith'
  3144.     verDoSave( actor ) = {}
  3145.     saveGame(actor) =
  3146.     {
  3147.         if (save( self.value ))
  3148.     {
  3149.             "Save failed. ";
  3150.         return nil;
  3151.     }
  3152.         else
  3153.     {
  3154.             "Saved. ";
  3155.         return true;
  3156.     }
  3157.     }
  3158.     doSave( actor ) =
  3159.     {
  3160.     self.saveGame(actor);
  3161.     abort;
  3162.     }
  3163.     verDoRestore( actor ) = {}
  3164.     restoreGame(actor) =
  3165.     {
  3166.         if (restore( self.value ))
  3167.     {
  3168.             "Restore failed. ";
  3169.         return nil;
  3170.     }
  3171.         else
  3172.     {
  3173.             "Restored.\b";
  3174.         scoreStatus( global.score, global.turnsofar );
  3175.         Me.location.lookAround(true);
  3176.         return true;
  3177.     }
  3178.     }
  3179.     doRestore( actor ) =
  3180.     {
  3181.     self.restoreGame(actor);
  3182.         abort;
  3183.     }
  3184.     verDoScript( actor ) = {}
  3185.     startScripting(actor) =
  3186.     {
  3187.         logging( self.value );
  3188.         "Writing script file. ";
  3189.     }
  3190.     doScript( actor ) =
  3191.     {
  3192.     self.startScripting(actor);
  3193.         abort;
  3194.     }
  3195.     verDoSay( actor ) = {}
  3196.     doSay( actor ) =
  3197.     {
  3198.         "Okay, \""; say( self.value ); "\".";
  3199.     }
  3200. ;
  3201.  
  3202. /*
  3203.  *  deepverb: object
  3204.  *
  3205.  *  A "verb object" that is referenced by the parser when the player
  3206.  *  uses an associated vocabulary word.  A deepverb contains both
  3207.  *  the vocabulary of the verb and a description of available syntax.
  3208.  *  The verb property lists the verb vocabulary words;
  3209.  *  one word (such as 'take') or a pair (such as 'pick up')
  3210.  *  can be used.  In the latter case, the second word must be a
  3211.  *  preposition, and may move to the end of the sentence in a player's
  3212.  *  command, as in "pick it up."  The action(actor)
  3213.  *  method specifies what happens when the verb is used without any
  3214.  *  objects; its absence specifies that the verb cannot be used without
  3215.  *  an object.  The doAction specifies the root of the message
  3216.  *  names (in single quotes) sent to the direct object when the verb
  3217.  *  is used with a direct object; its absence means that a single object
  3218.  *  is not allowed.  Likewise, the ioAction(preposition)
  3219.  *  specifies the root of the message name sent to the direct and
  3220.  *  indirect objects when the verb is used with both a direct and
  3221.  *  indirect object; its absence means that this syntax is illegal.
  3222.  *  Several ioAction properties may be present:  one for each
  3223.  *  preposition that can be used with an indirect object with the verb.
  3224.  *  
  3225.  *  The validDo(actor, object, seqno) method returns true
  3226.  *  if the indicated object is valid as a direct object for this actor.
  3227.  *  The validIo(actor, object, seqno) method does likewise
  3228.  *  for indirect objects.  The seqno parameter is a "sequence
  3229.  *  number," starting with 1 for the first object tried for a given
  3230.  *  verb, 2 for the second, and so forth; this parameter is normally
  3231.  *  ignored, but can be used for some special purposes.  For example,
  3232.  *  askVerb does not distinguish between objects matching vocabulary
  3233.  *  words, and therefore accepts only the first from a set of ambiguous
  3234.  *  objects.  These methods do not normally need to be changed; by
  3235.  *  default, they return true if the object is accessible to the
  3236.  *  actor.
  3237.  *  
  3238.  *  The doDefault(actor, prep, indirectObject) and
  3239.  *  ioDefault(actor, prep) methods return a list of the
  3240.  *  default direct and indirect objects, respectively.  These lists
  3241.  *  are used for determining which objects are meant by "all" and which
  3242.  *  should be used when the player command is missing an object.  These
  3243.  *  normally return a list of all objects that are applicable to the
  3244.  *  current command.
  3245.  *  
  3246.  *  The validDoList(actor, prep, indirectObject) and
  3247.  *  validIoList(actor, prep, directObject) methods return
  3248.  *  a list of all of the objects for which validDo would be true.
  3249.  *  Remember to include floating objects, which are generally
  3250.  *  accessible.  Note that the objects returned by this list will
  3251.  *  still be submitted by the parser to validDo, so it's okay for
  3252.  *  this routine to return too many objects.  In fact, this
  3253.  *  routine is entirely unnecessary; if you omit it altogether, or
  3254.  *  make it return nil, the parser will simply submit every
  3255.  *  object matching the player's vocabulary words to validDo.
  3256.  *  The reason to provide this method is that it can significantly
  3257.  *  improve parsing speed when the game has lots of objects that
  3258.  *  all have the same vocabulary word, because it cuts down on the
  3259.  *  number of times that validDo has to be called (each call
  3260.  *  to validDo is fairly time-consuming).
  3261.  */
  3262. class deepverb: object                // A deep-structure verb.
  3263.     validDo( actor, obj, seqno ) =
  3264.     {
  3265.         return( obj.isReachable( actor ));
  3266.     }
  3267.     validDoList(actor, prep, iobj) =
  3268.     {
  3269.     local ret;
  3270.     local loc;
  3271.  
  3272.     loc := actor.location;
  3273.     while (loc.location) loc := loc.location;
  3274.     ret := visibleList(actor) + visibleList(loc)
  3275.            + global.floatingList;
  3276.     return(ret);
  3277.     }
  3278.     validIo( actor, obj, seqno ) =
  3279.     {
  3280.         return( obj.isReachable( actor ));
  3281.     }
  3282.     validIoList(actor, prep, dobj) = (self.validDoList(actor, prep, dobj))
  3283.     doDefault( actor, prep, io ) =
  3284.     {
  3285.         return( actor.contents + actor.location.contents );
  3286.     }
  3287.     ioDefault( actor, prep ) =
  3288.     {
  3289.         return( actor.contents + actor.location.contents );
  3290.     }
  3291. ;
  3292.  
  3293. /*
  3294.    Dark verb - a verb that can be used in the dark.  Travel verbs
  3295.    are all dark verbs, as are system verbs (quit, save, etc.).
  3296.    In addition, certain special verbs are usable in the dark:  for
  3297.    example, you can drop objects you are carrying, and you can turn
  3298.    on light sources you are carrying. 
  3299. */
  3300.  
  3301. class darkVerb: deepverb
  3302.    isDarkVerb = true
  3303. ;
  3304.  
  3305. /*
  3306.  *   Various verbs.
  3307.  */
  3308. inspectVerb: deepverb
  3309.     verb = 'inspect' 'examine' 'look at' 'l at' 'x'
  3310.     sdesc = "inspect"
  3311.     doAction = 'Inspect'
  3312.     validDo( actor, obj, seqno ) =
  3313.     {
  3314.         return( obj.isVisible( actor ));
  3315.     }
  3316. ;
  3317. askVerb: deepverb
  3318.     verb = 'ask'
  3319.     sdesc = "ask"
  3320.     prepDefault = aboutPrep
  3321.     ioAction( aboutPrep ) = 'AskAbout'
  3322.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3323.     validIoList(actor, prep, dobj) = (nil)
  3324. ;
  3325. tellVerb: deepverb
  3326.     verb = 'tell'
  3327.     sdesc = "tell"
  3328.     prepDefault = aboutPrep
  3329.     ioAction( aboutPrep ) = 'TellAbout'
  3330.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3331.     validIoList(actor, prep, dobj) = (nil)
  3332.     ioDefault( actor, prep ) =
  3333.     {
  3334.         if (prep = aboutPrep)
  3335.         return([]);
  3336.     else
  3337.         return(actor.contents + actor.location.contents);
  3338.     }
  3339. ;
  3340. followVerb: deepverb
  3341.     sdesc = "follow"
  3342.     verb = 'follow'
  3343.     doAction = 'Follow'
  3344. ;
  3345. digVerb: deepverb
  3346.     verb = 'dig' 'dig in'
  3347.     sdesc = "dig in"
  3348.     prepDefault = withPrep
  3349.     ioAction( withPrep ) = 'DigWith'
  3350. ;
  3351. jumpVerb: deepverb
  3352.     verb = 'jump' 'jump over' 'jump off'
  3353.     sdesc = "jump"
  3354.     doAction = 'Jump'
  3355.     action(actor) = { "Wheeee!"; }
  3356. ;
  3357. pushVerb: deepverb
  3358.     verb = 'push' 'press'
  3359.     sdesc = "push"
  3360.     doAction = 'Push'
  3361. ;
  3362. attachVerb: deepverb
  3363.     verb = 'attach' 'connect'
  3364.     sdesc = "attach"
  3365.     prepDefault = toPrep
  3366.     ioAction( toPrep ) = 'AttachTo'
  3367. ;
  3368. wearVerb: deepverb
  3369.     verb = 'wear' 'put on'
  3370.     sdesc = "wear"
  3371.     doAction = 'Wear'
  3372. ;
  3373. dropVerb: deepverb, darkVerb
  3374.     verb = 'drop' 'put down'
  3375.     sdesc = "drop"
  3376.     ioAction( onPrep ) = 'PutOn'
  3377.     doAction = 'Drop'
  3378.     doDefault( actor, prep, io ) =
  3379.     {
  3380.         return( actor.contents );
  3381.     }
  3382. ;
  3383. removeVerb: deepverb
  3384.     verb = 'take off'
  3385.     sdesc = "take off"
  3386.     doAction = 'Unwear'
  3387.     ioAction( fromPrep ) = 'RemoveFrom'
  3388. ;
  3389. openVerb: deepverb
  3390.     verb = 'open'
  3391.     sdesc = "open"
  3392.     doAction = 'Open'
  3393. ;
  3394. closeVerb: deepverb
  3395.     verb = 'close'
  3396.     sdesc = "close"
  3397.     doAction = 'Close'
  3398. ;
  3399. putVerb: deepverb
  3400.     verb = 'put' 'place'
  3401.     sdesc = "put"
  3402.     prepDefault = inPrep
  3403.     ioAction( inPrep ) = 'PutIn'
  3404.     ioAction( onPrep ) = 'PutOn'
  3405.     doDefault( actor, prep, io ) =
  3406.     {
  3407.         return( takeVerb.doDefault( actor, prep, io ) + actor.contents );
  3408.     }
  3409. ;
  3410. takeVerb: deepverb                   // This object defines how to take things
  3411.     verb = 'take' 'pick up' 'get' 'remove'
  3412.     sdesc = "take"
  3413.     ioAction( offPrep ) = 'TakeOff'
  3414.     ioAction( outPrep ) = 'TakeOut'
  3415.     ioAction( fromPrep ) = 'TakeOut'
  3416.     ioAction( inPrep ) = 'TakeOut'
  3417.     ioAction( onPrep ) = 'TakeOff'
  3418.     doAction = 'Take'
  3419.     doDefault( actor, prep, io ) =
  3420.     {
  3421.         local ret, rem, cur, rem2, cur2, tot, i, tot2, j;
  3422.     
  3423.     ret := [];
  3424.         
  3425.     /*
  3426.      *   For "take all out/off of <iobj>", return the (non-fixed)
  3427.      *   contents of the indirect object.  Same goes for "take all in
  3428.      *   <iobj>", "take all on <iobj>", and "take all from <iobj>".
  3429.      */
  3430.     if (( prep=outPrep or prep=offPrep or prep=inPrep or prep=onPrep
  3431.      or prep=fromPrep ) and io<>nil )
  3432.     {
  3433.         rem := io.contents;
  3434.         i := 1;
  3435.         tot := length( rem );
  3436.         while ( i <= tot )
  3437.         {
  3438.             cur := rem[i];
  3439.             if (not cur.isfixed and self.validDo(actor, cur, i))
  3440.             ret += cur;
  3441.         ++i;
  3442.         }
  3443.             return( ret );
  3444.     }
  3445.  
  3446.         /*
  3447.      *   In the general case, return everything that's not fixed
  3448.      *   in the actor's location, or everything inside fixed containers
  3449.      *   that isn't itself fixed.
  3450.      */
  3451.         rem := actor.location.contents;
  3452.     tot := length( rem );
  3453.     i := 1;
  3454.         while ( i <= tot )
  3455.         {
  3456.         cur := rem[i];
  3457.             if ( cur.isfixed )
  3458.             {
  3459.                 if ((( cur.isopenable and cur.isopen ) or
  3460.                   ( not cur.isopenable )) and ( not cur.isactor ))
  3461.                 {
  3462.                     rem2 := cur.contents;
  3463.             tot2 := length( rem2 );
  3464.             j := 1;
  3465.                     while ( j <= tot2 )
  3466.                     {
  3467.                 cur2 := rem2[j];
  3468.                         if ( not cur2.isfixed and not cur2.notakeall )
  3469.             {
  3470.                 ret := ret + cur2;
  3471.             }
  3472.                         j := j + 1;
  3473.                     }
  3474.                 }
  3475.             }
  3476.             else if ( not cur.notakeall )
  3477.         {
  3478.             ret := ret + cur;
  3479.         }
  3480.  
  3481.         i := i + 1;            
  3482.         }
  3483.         return( ret );
  3484.     }
  3485. ;
  3486. plugVerb: deepverb
  3487.     verb = 'plug'
  3488.     sdesc = "plug"
  3489.     prepDefault = inPrep
  3490.     ioAction( inPrep ) = 'PlugIn'
  3491. ;
  3492. lookInVerb: deepverb
  3493.     verb = 'look in' 'look on' 'l in' 'l on'
  3494.     sdesc = "look in"
  3495.     doAction = 'Lookin'
  3496. ;
  3497. screwVerb: deepverb
  3498.     verb = 'screw'
  3499.     sdesc = "screw"
  3500.     ioAction( withPrep ) = 'ScrewWith'
  3501.     doAction = 'Screw'
  3502. ;
  3503. unscrewVerb: deepverb
  3504.     verb = 'unscrew'
  3505.     sdesc = "unscrew"
  3506.     ioAction( withPrep ) = 'UnscrewWith'
  3507.     doAction = 'Unscrew'
  3508. ;
  3509. turnVerb: deepverb
  3510.     verb = 'turn' 'rotate' 'twist'
  3511.     sdesc = "turn"
  3512.     ioAction( toPrep ) = 'TurnTo'
  3513.     ioAction( withPrep ) = 'TurnWith'
  3514.     doAction = 'Turn'
  3515. ;
  3516. switchVerb: deepverb
  3517.     verb = 'switch'
  3518.     sdesc = "switch"
  3519.     doAction = 'Switch'
  3520. ;
  3521. flipVerb: deepverb
  3522.     verb = 'flip'
  3523.     sdesc = "flip"
  3524.     doAction = 'Flip'
  3525. ;
  3526. turnOnVerb: deepverb, darkVerb
  3527.     verb = 'activate' 'turn on' 'switch on'
  3528.     sdesc = "turn on"
  3529.     doAction = 'Turnon'
  3530. ;
  3531. turnOffVerb: deepverb
  3532.     verb = 'turn off' 'deactiv' 'switch off'
  3533.     sdesc = "turn off"
  3534.     doAction = 'Turnoff'
  3535. ;
  3536. lookVerb: deepverb
  3537.     verb = 'look' 'l' 'look around' 'l around'
  3538.     sdesc = "look"
  3539.     action( actor ) =
  3540.     {
  3541.         actor.location.lookAround( true );
  3542.     }
  3543. ;
  3544. sitVerb: deepverb
  3545.     verb = 'sit on' 'sit in' 'sit' 'sit down' 'sit downin' 'sit downon'
  3546.     sdesc = "sit on"
  3547.     doAction = 'Siton'
  3548. ;
  3549. lieVerb: deepverb
  3550.     verb = 'lie' 'lie on' 'lie in' 'lie down' 'lie downon' 'lie downin'
  3551.     sdesc = "lie on"
  3552.     doAction = 'Lieon'
  3553. ;
  3554. getOutVerb: deepverb
  3555.     verb = 'get out' 'get outof' 'get off' 'get offof'
  3556.     sdesc = "get out of"
  3557.     doAction = 'Unboard'
  3558.     action(actor) = { askdo; }
  3559.     doDefault( actor, prep, io ) =
  3560.     {
  3561.         if ( actor.location and actor.location.location )
  3562.             return( [] + actor.location );
  3563.         else return( [] );
  3564.     }
  3565. ;
  3566. boardVerb: deepverb
  3567.     verb = 'get in' 'get into' 'board' 'get on'
  3568.     sdesc = "get on"
  3569.     doAction = 'Board'
  3570. ;
  3571. againVerb: darkVerb         // Required verb:  repeats last command.  No
  3572.                             // action routines are necessary; this one's
  3573.                             // handled internally by the parser.
  3574.     verb = 'again' 'g'
  3575. ;
  3576. waitVerb: darkVerb
  3577.     verb = 'wait' 'z'
  3578.     action( actor ) =
  3579.     {
  3580.         "Time passes...\n";
  3581.     }
  3582. ;
  3583. iVerb: deepverb
  3584.     verb = 'inventory' 'i'
  3585.     action( actor ) =
  3586.     {
  3587.         if (length( actor.contents ))
  3588.         {
  3589.             "%You% %have% "; listcont( actor ); ". ";
  3590.             listcontcont( actor );
  3591.         }
  3592.     else
  3593.             "%You% %are% empty-handed.\n";
  3594.     }
  3595. ;
  3596. lookThruVerb: deepverb
  3597.     verb = 'look through' 'look thru' 'l through' 'l thru'
  3598.     sdesc = "look through"
  3599.     doAction = 'Lookthru'
  3600. ;
  3601. breakVerb: deepverb
  3602.     verb = 'break' 'ruin' 'destroy'
  3603.     sdesc = "break"
  3604.     doAction = 'Break'
  3605. ;
  3606. attackVerb: deepverb
  3607.     verb = 'attack' 'kill' 'hit'
  3608.     sdesc = "attack"
  3609.     prepDefault = withPrep
  3610.     ioAction( withPrep ) = 'AttackWith'
  3611. ;
  3612. climbVerb: deepverb
  3613.     verb = 'climb'
  3614.     sdesc = "climb"
  3615.     doAction = 'Climb'
  3616. ;
  3617. eatVerb: deepverb
  3618.     verb = 'eat' 'consume'
  3619.     sdesc = "eat"
  3620.     doAction = 'Eat'
  3621. ;
  3622. drinkVerb: deepverb
  3623.     verb = 'drink'
  3624.     sdesc = "drink"
  3625.     doAction = 'Drink'
  3626. ;
  3627. giveVerb: deepverb
  3628.     verb = 'give' 'offer'
  3629.     sdesc = "give"
  3630.     prepDefault = toPrep
  3631.     ioAction( toPrep ) = 'GiveTo'
  3632.     doDefault( actor, prep, io ) =
  3633.     {
  3634.         return( actor.contents );
  3635.     }
  3636. ;
  3637. pullVerb: deepverb
  3638.     verb = 'pull'
  3639.     sdesc = "pull"
  3640.     doAction = 'Pull'
  3641. ;
  3642. readVerb: deepverb
  3643.     verb = 'read'
  3644.     sdesc = "read"
  3645.     doAction = 'Read'
  3646. ;
  3647. throwVerb: deepverb
  3648.     verb = 'throw' 'toss'
  3649.     sdesc = "throw"
  3650.     prepDefault = atPrep
  3651.     ioAction( atPrep ) = 'ThrowAt'
  3652.     ioAction( toPrep ) = 'ThrowTo'
  3653. ;
  3654. standOnVerb: deepverb
  3655.     verb = 'stand on'
  3656.     sdesc = "stand on"
  3657.     doAction = 'Standon'
  3658. ;
  3659. standVerb: deepverb
  3660.     verb = 'stand' 'stand up' 'get up'
  3661.     sdesc = "stand"
  3662.     action( actor ) =
  3663.     {
  3664.         if ( actor.location=nil or actor.location.location = nil )
  3665.             "%You're% already standing! ";
  3666.         else
  3667.         {
  3668.         actor.location.doUnboard( actor );
  3669.         }
  3670.     }
  3671. ;
  3672. helloVerb: deepverb
  3673.     verb = 'hello' 'hi' 'greetings'
  3674.     action( actor ) =
  3675.     {
  3676.         "Nice weather we've been having.\n";
  3677.     }
  3678. ;
  3679. showVerb: deepverb
  3680.     verb = 'show'
  3681.     sdesc = "show"
  3682.     prepDefault = toPrep
  3683.     ioAction( toPrep ) = 'ShowTo'
  3684.     doDefault( actor, prep, io ) =
  3685.     {
  3686.         return( actor.contents );
  3687.     }
  3688. ;
  3689. cleanVerb: deepverb
  3690.     verb = 'clean'
  3691.     sdesc = "clean"
  3692.     ioAction( withPrep ) = 'CleanWith'
  3693.     doAction = 'Clean'
  3694. ;
  3695. sayVerb: deepverb
  3696.     verb = 'say'
  3697.     sdesc = "say"
  3698.     doAction = 'Say'
  3699. ;
  3700. yellVerb: deepverb
  3701.     verb = 'yell' 'shout' 'yell at' 'shout at'
  3702.     action( actor ) =
  3703.     {
  3704.         "%Your% throat is a bit sore now. ";
  3705.     }
  3706. ;
  3707. moveVerb: deepverb
  3708.     verb = 'move'
  3709.     sdesc = "move"
  3710.     ioAction( withPrep ) = 'MoveWith'
  3711.     ioAction( toPrep ) = 'MoveTo'
  3712.     doAction = 'Move'
  3713. ;
  3714. fastenVerb: deepverb
  3715.     verb = 'fasten' 'buckle' 'buckle up'
  3716.     sdesc = "fasten"
  3717.     doAction = 'Fasten'
  3718. ;
  3719. unfastenVerb: deepverb
  3720.     verb = 'unfasten' 'unbuckle'
  3721.     sdesc = "unfasten"
  3722.     doAction = 'Unfasten'
  3723. ;
  3724. unplugVerb: deepverb
  3725.     verb = 'unplug'
  3726.     sdesc = "unplug"
  3727.     ioAction( fromPrep ) = 'UnplugFrom'
  3728.     doAction = 'Unplug'
  3729. ;
  3730. lookUnderVerb: deepverb
  3731.     verb = 'look under' 'look beneath' 'l under' 'l beneath'
  3732.     sdesc = "look under"
  3733.     doAction = 'Lookunder'
  3734. ;
  3735. lookBehindVerb: deepverb
  3736.     verb = 'look behind' 'l behind'
  3737.     sdesc = "look behind"
  3738.     doAction = 'Lookbehind'
  3739. ;
  3740. typeVerb: deepverb
  3741.     verb = 'type'
  3742.     sdesc = "type"
  3743.     prepDefault = onPrep
  3744.     ioAction( onPrep ) = 'TypeOn'
  3745. ;
  3746. lockVerb: deepverb
  3747.     verb = 'lock'
  3748.     sdesc = "lock"
  3749.     ioAction( withPrep ) = 'LockWith'
  3750.     doAction = 'Lock'
  3751.     prepDefault = withPrep
  3752. ;
  3753. unlockVerb: deepverb
  3754.     verb = 'unlock'
  3755.     sdesc = "unlock"
  3756.     ioAction( withPrep ) = 'UnlockWith'
  3757.     doAction = 'Unlock'
  3758.     prepDefault = withPrep
  3759. ;
  3760. detachVerb: deepverb
  3761.     verb = 'detach' 'disconnect'
  3762.     prepDefault = fromPrep
  3763.     ioAction( fromPrep ) = 'DetachFrom'
  3764.     doAction = 'Detach'
  3765.     sdesc = "detach"
  3766. ;
  3767. sleepVerb: darkVerb
  3768.     action( actor ) =
  3769.     {
  3770.         if ( actor.cantSleep )
  3771.             "%You% %are% much too anxious worrying about %your% continued
  3772.             survival to fall asleep now. ";
  3773.         else if ( global.awakeTime+1 < global.sleepTime )
  3774.             "%You're% not tired. ";
  3775.         else if ( not ( actor.location.isbed or actor.location.ischair ))
  3776.             "I don't know about you, but I can never sleep
  3777.             standing up. %You% should find a nice comfortable
  3778.             bed somewhere. ";
  3779.         else
  3780.         {
  3781.             "%You% quickly drift%s% off into dreamland...\b";
  3782.             goToSleep();
  3783.         }
  3784.     }
  3785.     verb = 'sleep'
  3786. ;
  3787. pokeVerb: deepverb
  3788.     verb = 'poke' 'jab'
  3789.     sdesc = "poke"
  3790.     doAction = 'Poke'
  3791. ;
  3792. touchVerb: deepverb
  3793.     verb = 'touch'
  3794.     sdesc = "touch"
  3795.     doAction = 'Touch'
  3796. ;
  3797. moveNVerb: deepverb
  3798.     verb = 'move north' 'move n' 'push north' 'push n'
  3799.     sdesc = "move north"
  3800.     doAction = 'MoveN'
  3801. ;
  3802. moveSVerb: deepverb
  3803.     verb = 'move south' 'move s' 'push south' 'push s'
  3804.     sdesc = "move south"
  3805.     doAction = 'MoveS'
  3806. ;
  3807. moveEVerb: deepverb
  3808.     verb = 'move east' 'move e' 'push east' 'push e'
  3809.     sdesc = "move east"
  3810.     doAction = 'MoveE'
  3811. ;
  3812. moveWVerb: deepverb
  3813.     verb = 'move west' 'move w' 'push west' 'push w'
  3814.     sdesc = "move west"
  3815.     doAction = 'MoveW'
  3816. ;
  3817. moveNEVerb: deepverb
  3818.     verb = 'move northeast' 'move ne' 'push northeast' 'push ne'
  3819.     sdesc = "move northeast"
  3820.     doAction = 'MoveNE'
  3821. ;
  3822. moveNWVerb: deepverb
  3823.     verb = 'move northwest' 'move nw' 'push northwest' 'push nw'
  3824.     sdesc = "move northwest"
  3825.     doAction = 'MoveNW'
  3826. ;
  3827. moveSEVerb: deepverb
  3828.     verb = 'move southeast' 'move se' 'push southeast' 'push se'
  3829.     sdesc = "move southeast"
  3830.     doAction = 'MoveSE'
  3831. ;
  3832. moveSWVerb: deepverb
  3833.     verb = 'move southwest' 'move sw' 'push southwest' 'push sw'
  3834.     sdesc = "move southwest"
  3835.     doAction = 'MoveSW'
  3836. ;
  3837. centerVerb: deepverb
  3838.     verb = 'center'
  3839.     sdesc = "center"
  3840.     doAction = 'Center'
  3841. ;
  3842. searchVerb: deepverb
  3843.     verb = 'search'
  3844.     sdesc = "search"
  3845.     doAction = 'Search'
  3846. ;
  3847.  
  3848. /*
  3849.  *   Travel verbs  - these verbs allow the player to move about.
  3850.  *   All travel verbs have the property isTravelVerb set true.
  3851.  */
  3852. class travelVerb: deepverb, darkVerb
  3853.     isTravelVerb = true
  3854. ;
  3855.  
  3856. eVerb: travelVerb
  3857.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3858.     verb = 'e' 'east' 'go east'
  3859.     travelDir( actor ) = { return( actor.location.east ); }
  3860. ;
  3861. sVerb: travelVerb
  3862.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3863.     verb = 's' 'south' 'go south'
  3864.     travelDir( actor ) = { return( actor.location.south ); }
  3865. ;
  3866. nVerb: travelVerb
  3867.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3868.     verb = 'n' 'north' 'go north'
  3869.     travelDir( actor ) = { return( actor.location.north ); }
  3870. ;
  3871. wVerb: travelVerb
  3872.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3873.     verb = 'w' 'west' 'go west'
  3874.     travelDir( actor ) = { return( actor.location.west ); }
  3875. ;
  3876. neVerb: travelVerb
  3877.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3878.     verb = 'ne' 'northeast' 'go ne' 'go northeast'
  3879.     travelDir( actor ) = { return( actor.location.ne ); }
  3880. ;
  3881. nwVerb: travelVerb
  3882.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3883.     verb = 'nw' 'northwest' 'go nw' 'go northwest'
  3884.     travelDir( actor ) = { return( actor.location.nw ); }
  3885. ;
  3886. seVerb: travelVerb
  3887.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3888.     verb = 'se' 'southeast' 'go se' 'go southeast'
  3889.     travelDir( actor ) = { return( actor.location.se ); }
  3890. ;
  3891. swVerb: travelVerb
  3892.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3893.     verb = 'sw' 'southwest' 'go sw' 'go southwest'
  3894.     travelDir( actor ) = { return( actor.location.sw ); }
  3895. ;
  3896. inVerb: travelVerb
  3897.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3898.     verb = 'in' 'go in' 'enter'
  3899.     sdesc = "enter"
  3900.     doAction = 'Enter'
  3901.     travelDir( actor ) = { return( actor.location.in ); }
  3902.     ioAction(onPrep) = 'EnterOn'
  3903.     ioAction(inPrep) = 'EnterIn'
  3904.     ioAction(withPrep) = 'EnterWith'
  3905. ;
  3906. outVerb: travelVerb
  3907.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3908.     verb = 'out' 'go out' 'exit' 'leave'
  3909.     travelDir( actor ) = { return( actor.location.out ); }
  3910. ;
  3911. dVerb: travelVerb
  3912.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3913.     verb = 'd' 'down' 'go down'
  3914.     travelDir( actor ) = { return( actor.location.down ); }
  3915. ;
  3916. uVerb: travelVerb
  3917.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3918.     verb = 'u' 'up' 'go up'
  3919.     travelDir( actor ) = { return( actor.location.up ); }
  3920. ;
  3921.  
  3922. /*
  3923.  *   sysverb:  A system verb.  Verbs of this class are special verbs that
  3924.  *   can be executed without certain normal validations.  For example,
  3925.  *   a system verb can be executed in a dark room.  System verbs are
  3926.  *   for operations such as saving, restoring, and quitting, which are
  3927.  *   not really part of the game.
  3928.  */
  3929. class sysverb: deepverb, darkVerb
  3930.     issysverb = true
  3931. ;
  3932.  
  3933. quitVerb: sysverb
  3934.     verb = 'quit'
  3935.     quitGame(actor) =
  3936.     {
  3937.         local yesno;
  3938.  
  3939.         scoreRank();
  3940.         "\bDo you really want to quit? (YES or NO) > ";
  3941.         yesno := yorn();
  3942.         "\b";
  3943.         if ( yesno = 1 )
  3944.         {
  3945.             terminate();    // allow user good-bye message
  3946.         quit();
  3947.         }
  3948.         else
  3949.         {
  3950.             "Okay. ";
  3951.         }
  3952.     }
  3953.     action( actor ) =
  3954.     {
  3955.     self.quitGame(actor);
  3956.     abort;
  3957.     }
  3958. ;
  3959. verboseVerb: sysverb
  3960.     verb = 'verbose'
  3961.     verboseMode(actor) =
  3962.     {
  3963.         "Okay, now in VERBOSE mode.\n";
  3964.         global.verbose := true;
  3965.     Me.location.lookAround( true );
  3966.     }
  3967.     action( actor ) =
  3968.     {
  3969.     self.verboseMode(actor);
  3970.     abort;
  3971.     }
  3972. ;
  3973. terseVerb: sysverb
  3974.     verb = 'brief' 'terse'
  3975.     terseMode(actor) =
  3976.     {
  3977.         "Okay, now in TERSE mode.\n";
  3978.         global.verbose := nil;
  3979.     }
  3980.     action( actor ) =
  3981.     {
  3982.     self.terseMode(actor);
  3983.     abort;
  3984.     }
  3985. ;
  3986. scoreVerb: sysverb
  3987.     verb = 'score' 'status'
  3988.     showScore(actor) =
  3989.     {
  3990.         scoreRank();
  3991.     }
  3992.     action( actor ) =
  3993.     {
  3994.     self.showScore(actor);
  3995.     abort;
  3996.     }
  3997. ;
  3998. saveVerb: sysverb
  3999.     verb = 'save'
  4000.     sdesc = "save"
  4001.     doAction = 'Save'
  4002.     saveGame(actor) =
  4003.     {
  4004.         local savefile;
  4005.     
  4006.     savefile := askfile( 'File to save game in' );
  4007.     if ( savefile = nil or savefile = '' )
  4008.         {
  4009.         "Failed. ";
  4010.             return nil;
  4011.     }
  4012.     else if (save( savefile ))
  4013.         {
  4014.         "Saved failed. ";
  4015.             return nil;
  4016.     }
  4017.     else
  4018.     {
  4019.         "Saved. ";
  4020.             return true;
  4021.     }
  4022.     }
  4023.     action( actor ) =
  4024.     {
  4025.     self.saveGame(actor);
  4026.     abort;
  4027.     }
  4028. ;
  4029. restoreVerb: sysverb
  4030.     verb = 'restore'
  4031.     sdesc = "restore"
  4032.     doAction = 'Restore'
  4033.     restoreGame(actor) =
  4034.     {
  4035.         local savefile;
  4036.     
  4037.     savefile := askfile( 'File to restore game from' );
  4038.     if ( savefile = nil or savefile = '' )
  4039.         {
  4040.         "Failed. ";
  4041.             return nil;
  4042.     }
  4043.     else if (restore( savefile ))
  4044.         {
  4045.         "Restore failed. ";
  4046.             return nil;
  4047.     }
  4048.     else
  4049.     {
  4050.         scoreStatus(global.score, global.turnsofar);
  4051.         "Restored.\b";
  4052.         Me.location.lookAround(true);
  4053.         return true;
  4054.     }
  4055.     }
  4056.     action( actor ) =
  4057.     {
  4058.     self.restoreGame(actor);
  4059.     abort;
  4060.     }
  4061. ;
  4062. scriptVerb: sysverb
  4063.     verb = 'script'
  4064.     doAction = 'Script'
  4065.     startScripting(actor) =
  4066.     {
  4067.         local scriptfile;
  4068.     
  4069.     scriptfile := askfile( 'File to write transcript to' );
  4070.     if ( scriptfile = nil or scriptfile = '' )
  4071.         "Failed. ";
  4072.     else
  4073.     {
  4074.         logging( scriptfile );
  4075.         "All text will now be saved to the script file.
  4076.             Type UNSCRIPT at any time to discontinue scripting.";
  4077.     }
  4078.     }
  4079.     action( actor ) =
  4080.     {
  4081.     self.startScripting(actor);
  4082.     abort;
  4083.     }
  4084. ;
  4085. unscriptVerb: sysverb
  4086.     verb = 'unscript'
  4087.     stopScripting(actor) =
  4088.     {
  4089.         logging( nil );
  4090.         "Script closed.\n";
  4091.     }
  4092.     action( actor ) =
  4093.     {
  4094.     self.stopScripting(actor);
  4095.         abort;
  4096.     }
  4097. ;
  4098. restartVerb: sysverb
  4099.     verb = 'restart'
  4100.     restartGame(actor) =
  4101.     {
  4102.         local yesno;
  4103.         while ( true )
  4104.         {
  4105.             "Are you sure you want to start over? (YES or NO) > ";
  4106.             yesno := yorn();
  4107.             if ( yesno = 1 )
  4108.             {
  4109.                 "\n";
  4110.         scoreStatus(0, 0);
  4111.                 restart(initRestart, global.initRestartParam);
  4112.                 break;
  4113.             }
  4114.             else if ( yesno = 0 )
  4115.             {
  4116.                 "\nOkay.\n";
  4117.         break;
  4118.             }
  4119.         }
  4120.     }
  4121.     action( actor ) =
  4122.     {
  4123.     self.restartGame(actor);
  4124.     abort;
  4125.     }
  4126. ;
  4127. versionVerb: sysverb
  4128.     verb = 'version'
  4129.     showVersion(actor) =
  4130.     {
  4131.         version.sdesc;
  4132.     }
  4133.     action( actor ) =
  4134.     {
  4135.     self.showVersion(actor);
  4136.         abort;
  4137.     }
  4138. ;
  4139. debugVerb: sysverb
  4140.     verb = 'debug'
  4141.     enterDebugger(actor) =
  4142.     {
  4143.     if (debugTrace())
  4144.         "You can't think this game has any bugs left in it... ";
  4145.     }
  4146.     action( actor ) =
  4147.     {
  4148.     self.enterDebugger(actor);
  4149.     abort;
  4150.     }
  4151. ;
  4152.  
  4153. undoVerb: sysverb
  4154.     verb = 'undo'
  4155.     undoMove(actor) =
  4156.     {
  4157.     /* do TWO undo's - one for this 'undo', one for previous command */
  4158.     if (undo() and undo())
  4159.     {
  4160.         "(Undoing one command)\b";
  4161.         Me.location.lookAround(true);
  4162.         scoreStatus(global.score, global.turnsofar);
  4163.     }
  4164.     else
  4165.         "No more undo information is available. ";
  4166.     }
  4167.     action(actor) =
  4168.     {
  4169.     self.undoMove(actor);
  4170.     abort;
  4171.     }
  4172. ;
  4173.  
  4174. /*
  4175.  *  Prep: object
  4176.  *
  4177.  *  A preposition.  The preposition property specifies the
  4178.  *  vocabulary word.
  4179.  */
  4180. class Prep: object
  4181. ;
  4182.  
  4183. /*
  4184.  *   Various prepositions
  4185.  */
  4186. ofPrep: Prep
  4187.     preposition = 'of'
  4188.     sdesc = "of"
  4189. ;
  4190. aboutPrep: Prep
  4191.     preposition = 'about'
  4192.     sdesc = "about"
  4193. ;
  4194. withPrep: Prep
  4195.     preposition = 'with'
  4196.     sdesc = "with"
  4197. ;
  4198. toPrep: Prep
  4199.     preposition = 'to'
  4200.     sdesc = "to"
  4201. ;
  4202. onPrep: Prep
  4203.     preposition = 'on' 'onto' 'downon' 'upon'
  4204.     sdesc = "on"
  4205. ;
  4206. inPrep: Prep
  4207.     preposition = 'in' 'into' 'downin'
  4208.     sdesc = "in"
  4209. ;
  4210. offPrep: Prep
  4211.     preposition = 'off' 'offof'
  4212.     sdesc = "off"
  4213. ;
  4214. outPrep: Prep
  4215.     preposition = 'out' 'outof'
  4216.     sdesc = "out"
  4217. ;
  4218. fromPrep: Prep
  4219.     preposition = 'from'
  4220.     sdesc = "from"
  4221. ;
  4222. betweenPrep: Prep
  4223.     preposition = 'between' 'inbetween'
  4224.     sdesc = "between"
  4225. ;
  4226. overPrep: Prep
  4227.     preposition = 'over'
  4228.     sdesc = "over"
  4229. ;
  4230. atPrep: Prep
  4231.     preposition = 'at'
  4232.     sdesc = "at"
  4233. ;
  4234. aroundPrep: Prep
  4235.     preposition = 'around'
  4236.     sdesc = "around"
  4237. ;
  4238. thruPrep: Prep
  4239.     preposition = 'through' 'thru'
  4240.     sdesc = "through"
  4241. ;
  4242. dirPrep: Prep
  4243.     preposition = 'north' 'south' 'east' 'west' 'up' 'down' 'northeast' 'ne'
  4244.                   'northwest' 'nw' 'southeast' 'se' 'southwest' 'sw'
  4245.     sdesc = "north"         // Shouldn't ever need this, but just in case
  4246. ;
  4247. underPrep: Prep
  4248.     preposition = 'under' 'beneath'
  4249.     sdesc = "under"
  4250. ;
  4251. behindPrep: Prep
  4252.     preposition = 'behind'
  4253.     sdesc = "behind"
  4254. ;
  4255.  
  4256. /*
  4257.  *   articles:  the "built-in" articles.  "The," "a," and "an" are
  4258.  *   defined.
  4259.  */
  4260. articles: object
  4261.     article = 'the' 'a' 'an'
  4262. ;
  4263.  
  4264.